69172023-12-19 18:24:52111Növekvő XORcpp17Time limit exceeded 45/1001.1s7216 KiB
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

#define pii pair<int, int>

int random(int l, int h) {
	static mt19937 gen;
	return uniform_int_distribution<int>(l, h)(gen);
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef CB
	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N = 1000;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		v[i] = random(1, 1000000000);
		cin >> v[i];
		bool ok = true;
		auto w = v;
		sort(w.rbegin(), w.rend());
		int l = 31;
		vector<int> b(33);
		vector<int> c(33);
		for (int i = 0; i <= N; i++) {
			if (i == N || __lg(w[i]) < l) {
				if (b[l] - c[l] > 1) {
					ok = false;
					break;
				}
				if (i == N) break;
				l = __lg(w[i]);
				for (int j = 0; j < 30; j++) {
					c[j]+=b[j];
					b[j] = 0;
				}
			}
			while (w[i]) {
				int bb = __lg(w[i]);
				b[bb]++;
				w[i] -= 1 << bb;
			}
		}
		cout << (ok ? "YES" : "NO") << '\n';
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1960 KiB
2Accepted3ms2188 KiB
subtask210/10
3Accepted3ms2408 KiB
4Accepted3ms2596 KiB
5Accepted3ms2812 KiB
6Accepted3ms3020 KiB
7Accepted3ms3108 KiB
8Accepted3ms3184 KiB
9Accepted3ms3100 KiB
10Accepted3ms3228 KiB
subtask30/11
11Accepted3ms3440 KiB
12Accepted3ms3528 KiB
13Time limit exceeded1.1s6136 KiB
14Time limit exceeded1.08s6004 KiB
15Time limit exceeded1.078s6260 KiB
subtask435/35
16Accepted116ms3952 KiB
17Accepted118ms4044 KiB
18Accepted118ms4128 KiB
19Accepted118ms4168 KiB
20Accepted118ms4164 KiB
21Accepted118ms4292 KiB
22Accepted118ms4524 KiB
23Accepted118ms4460 KiB
subtask50/44
24Time limit exceeded1.054s6792 KiB
25Time limit exceeded1.067s6720 KiB
26Time limit exceeded1.067s6756 KiB
27Time limit exceeded1.059s6616 KiB
28Time limit exceeded1.067s6812 KiB
29Time limit exceeded1.067s6816 KiB
30Time limit exceeded1.075s7060 KiB
31Time limit exceeded1.062s6952 KiB
32Time limit exceeded1.07s7216 KiB
33Time limit exceeded1.075s7124 KiB