QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#374673 | #8316. Random Permutation | PetroTarnavskyi# | TL | 0ms | 0kb | C++20 | 1000b | 2024-04-02 16:42:41 | 2024-04-02 16:42:55 |
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int INF = 1e9 + 74;
void solve()
{
int n;
cin >> n;
VI a(n);
FOR (i, 0, n)
cin >> a[i];
int ans = 0;
FOR (i, 0, 1 << SZ(a))
{
VI f[2];
FOR (j, 0, SZ(a))
{
f[(i >> j) & 1].PB(a[j]);
}
VI res(2, INF);
FOR (t, 0, 2)
{
FOR (j, 0, SZ(f[t]))
{
FOR (k, j + 1, SZ(f[t]))
res[t] = min(res[t], f[t][j] ^ f[t][k]);
}
}
ans = max(ans, min(res[0], res[1]));
}
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
2