QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#374673#8316. Random PermutationPetroTarnavskyi#TL 0ms0kbC++201000b2024-04-02 16:42:412024-04-02 16:42:55

Judging History

你现在查看的是最新测评结果

  • [2024-04-02 16:42:55]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-04-02 16:42:41]
  • 提交

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

output:


result: