Created
January 27, 2021 13:33
-
-
Save hotsuyuki/cd295c27a49806bf4c7f69058d23f9f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
typedef unsigned long long ull; | |
using namespace std; | |
int main () { | |
ull test_cases; | |
cin >> test_cases; | |
while (test_cases--) { | |
ull num_elem; | |
cin >> num_elem; | |
vector<ull> elems(num_elem, 0); | |
for (ull i = 0; i < num_elem; ++i) { | |
cin >> elems[i]; | |
} | |
sort(elems.begin(), elems.end()); | |
ull min_xor = numeric_limits<ull>::max(); | |
for (ull i = 1; i < num_elem; ++i) { | |
// min_xor = min(min_xor, (elems[i - 1] & elems[i]) ^ (elems[i - 1] | elems[i])); | |
min_xor = min(min_xor, elems[i - 1] ^ elems[i]); | |
if (min_xor == 0) { | |
break; | |
} | |
} | |
cout << min_xor << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment