fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve()
  5. {
  6. long long n, x, y, temp = 0, s = 0, min = 0;
  7. cin >> n >> x >> y;
  8. priority_queue<long long, vector<long long>, greater<long long>> pq;
  9. for(long long i=0; i<n; i++)
  10. {
  11. cin >> temp;
  12. pq.push(temp);
  13. }
  14. for(long long i=0; i<y; i++)
  15. {
  16. min = pq.top();
  17. pq.pop();
  18. s = (min^x);
  19. pq.push(s);
  20. if((pq.top()^x) == min)
  21. {
  22. if(y%2==0)
  23. {
  24. break;
  25. }
  26. }
  27. }
  28. while (pq.empty() == false)
  29. {
  30. cout << pq.top() << " ";
  31. pq.pop();
  32. }
  33. cout << "\n";
  34. }
  35.  
  36. int main() {
  37. ios::sync_with_stdio(0);
  38. cin.tie(0);
  39. cout.tie(0);
  40. long long t;
  41. cin >> t;
  42. while(t--!=0)
  43. {
  44. solve();
  45. }
  46. return 0;
  47. }
Success #stdin #stdout 0s 5536KB
stdin
3
1 6 99
9
3 7 44
1 2 3
5 20 6
5 10 15 20 25
stdout
15 
4 5 6 
5 20 25 27 30