SHARE
TWEET

Untitled

a guest Sep 12th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2. #include <sstream>
  3. #include <vector>
  4. #include <bitset>
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main()
  10. {
  11.     ifstream in("input.txt");
  12.     ofstream out("output.txt");
  13.     int n, m;
  14.     vector<int> a;
  15.     in >> n;
  16.     for (int i = 0; i < n; i++)
  17.     {
  18.         int t;
  19.         in >> t;
  20.         a.push_back(t);
  21.     }
  22.     in >> m;
  23.     stringstream ss;
  24.     for (int i = 0; i < m; i++)
  25.     {
  26.         int b;
  27.         in >> b;
  28.         int max = b ^ a[0];
  29.         int indMax = a[0];
  30.         for (int j = 1; j < n; j++)
  31.         {
  32.             int t = b ^ a[j];
  33.             if (max < t)
  34.             {
  35.                 max = t;
  36.                 indMax = a[j];
  37.             }
  38.         }
  39.         ss << indMax << " ";
  40.     }
  41.     out << ss.str();
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top