fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. #define pb push_back
  6. #define sf(x) scanf("%d",&x)
  7. #define sfl(x) scanf("%lld",&x)
  8. #define pf(x) printf("%d\n",x)
  9. #define pfl(x) printf("%lld\n",x)
  10. #define endl '\n'
  11. #define pii pair<int,int>
  12. #define mapii map<int,int>
  13. #define mapll map<ll,ll>
  14. #define mapci map<char,int>
  15. #define mapcl map<char,ll>
  16. #define mapsi map<string,int>
  17. #define mapsl map<string,ll>
  18. #define pll pair<ll,ll>
  19. #define vi vector<int>
  20. #define vl vector<ll>
  21. #define vd vector<double,double>
  22. #define all(c) c.begin(),c.end()
  23. #define F first
  24. #define S second
  25. #define mp make_pair
  26. #define ftc(x) cerr << #x << ": " << x << " " << endl;
  27. #define PI acos(-1)
  28. #define lcm(a,b) ((a*b)/__gcd(a,b))
  29. #define optimize ios_base::sync_with_stdio(false);cin.tie(NULL);
  30. #define sqr(a) ((a)*(a))
  31.  
  32. int main()
  33. {
  34. int tst;
  35.  
  36. tst = 1;
  37.  
  38. // cin >> tst;
  39.  
  40. while(tst--)
  41. {
  42. ll i,j,k,l,m,n,x;
  43.  
  44. cin >> n >> k>> x;
  45.  
  46. ll ans = 0;
  47.  
  48. ll ar[n+10];
  49. ll ar1[n+10];
  50. ll ar2[n+10];
  51.  
  52. for(i=0; i<n; i++)cin >> ar[i];
  53.  
  54. sort(ar,ar+n);
  55.  
  56. for(i=0; i<n; i++)ar1[i] = ar[i];
  57. for(i=0; i<n; i+=2)ar1[i] = ar[i]^x;
  58.  
  59. sort(ar1,ar1+n);
  60.  
  61. for(i=0; i<n; i++)ar2[i] = ar1[i];
  62. for(i=0; i<n; i+=2)ar2[i] = ar1[i]^x;
  63.  
  64. sort(ar2,ar2+n);
  65.  
  66. if(k%2)
  67. {
  68. cout << ar1[n-1] << " " << ar1[0] << endl;
  69. }
  70. else cout << ar2[n-1] << " " << ar2[0] << endl;
  71. }
  72. }
Success #stdin #stdout 0s 4388KB
stdin
Standard input is empty
stdout
140736698057808 93157018495376