QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667239#9518. 观虫我 (旧版数据)251Sec0 5632ms14692kbC++142.0kb2024-10-22 21:48:192024-10-22 21:49:23

Judging History

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

  • [2024-10-22 21:49:23]
  • 评测
  • 测评结果:0
  • 用时:5632ms
  • 内存:14692kb
  • [2024-10-22 21:48:19]
  • 提交

answer

// 0: 枚举询问的子集
// 1: 枚举修改的超集
// 2: 枚举询问补集的子集和修改的子集
#include <bits/stdc++.h>
using namespace std;
typedef unsigned u32;
typedef unsigned long long u64;
mt19937 eng(363415);
int n, u, q;
struct Oper {
	bool op; u32 x;	
} a[1000005];
int typ[26], tmp[26], pos0, pos1, pos2;
u64 minW = -1, f[67200000];
int main() {
	scanf("%d%d", &n, &q), u = n - 6;
	for (int i = 1; i <= q; i++) {
		char op; u32 x; scanf(" %c%u", &op, &x);
		a[i] = { op == '?', x };
	}
	for (int T = 1; T <= 10; T++) {
		for (int i = 0; i < u; i++) tmp[i] = eng() % 3;
		u64 s = 0;
		for (int i = 1; i <= q; i++) {
			u32 x = a[i].x >> 6; u64 t = 1;
			for (int j = 0; j < u; j++) {
				if (a[i].op) {
					if ((x >> j & 1) && tmp[j] == 0) t <<= 1;
					if (!(x >> j & 1) && tmp[j] == 2) t <<= 1;
				}
				else {
					if (!(x >> j & 1) && tmp[j] == 1) t <<= 1;
					if ((x >> j & 1) && tmp[j] == 2) t <<= 1;
				}
			}
			s += t;
		}
		if (s < minW) {
			minW = s;
			memcpy(typ, tmp, sizeof(typ));
		}
	}
	for (int i = 0; i < u; i++) typ[i] = 0;
	for (int i = 0; i < u; i++) {
		if (typ[i] == 0) pos0 |= 1 << i;
		else if (typ[i] == 1) pos1 |= 1 << i;
		else pos2 |= 1 << i;
	}
	for (int id = 1; id <= q; id++) {
		u32 x = a[id].x >> 6, y = a[id].x & 63;
		if (a[id].op) {
			u64 res = 0;
			u32 a = (x & pos0) | (~x & pos2), b = (x & pos1);
			for (u32 s = a; s; s = (s - 1) & a) {
				res ^= f[s | b];
			}
			res ^= f[b];
			int ans = 0;
			for (u32 s = 0; s < 64; s++) {
				if ((y & s) == s) ans ^= (res >> s & 1);
			}
			putchar('0' ^ ans), putchar('\n');
		}
		else {
			u32 a = x & pos2, b = (x & pos1) | ~pos1, c = x & pos0;
			for (u32 s = a; s; s = (s - 1) & a) {
				for (u32 t = b; t < (1 << u) - 1; t = (t + 1) | b) {
					f[s | (t & pos1) | c] ^= 1ull << y;
				}
				f[s | pos1 | c] ^= 1ull << y;
			}
			for (u32 t = b; t < (1 << u) - 1; t = (t + 1) | b) {
				f[(t & pos1) | c] ^= 1ull << y;
			}
			f[pos1 | c] ^= 1ull << y;
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 20
Accepted
time: 5632ms
memory: 14692kb

input:

24 1000000
! 9475137
! 4501536
? 14277831
? 16695039
? 5723102
? 6093887
? 3014539
! 475969
? 12500973
! 8750136
? 15617895
! 4589313
! 152300
? 3612579
? 15248179
! 764162
! 4461105
? 7274495
? 13299697
! 8388872
? 13490383
! 3875594
! 9439685
? 16776189
! 6443172
? 13864879
! 395691
? 7142271
? 16...

output:

1
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
1
1
1
0
1
1
1
1
0
0
1
1
0
0
1
0
0
0
1
1
0
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
1
1
1
0
0
0
1
0
0
0
1
1
1
1
1
0
0
0
1
0
1
1
0
1
1
0
0
0
0
1
1
0
0
1
1
0
1
0
0
0
0
0
0
1
1
1
1
1
0
1
0
0
0
0
0
1
1
0
1
1
0
1
0
1
1
1
1
1
0
0
1
1
1
1
1
1
0
1
0
0
0
0
0
1
1
1
0
0
0
1
1
0
...

result:

ok Accepted.

Test #2:

score: 0
Time Limit Exceeded

input:

24 1000000
! 0
? 16777215
! 0
! 0
! 262144
? 16777215
? 16777215
? 15728639
! 0
? 16777215
? 16777215
! 16384
? 16777211
! 0
? 16777215
! 0
! 0
? 16760831
! 0
! 0
? 16777215
! 0
? 16777215
! 0
? 16777215
! 0
? 16777215
? 16777215
! 0
! 0
? 16777215
? 16777215
? 16777215
? 16777215
! 32768
? 16777215...

output:

1
0
0
0
1
1
0
1
0
1
0
1
0
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
1
0
0
0
1
0
0
1
0
1
0
0
1
1
1
1
1
1
0
1
1
0
0
1
1
0
0
0
1
0
1
0
1
0
1
0
1
1
1
0
0
1
0
1
0
0
0
0
0
1
0
0
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
0
1
0
1
0
0
1
1
1
1
0
0
0
0
1
1
1
1
1
0
1
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
...

result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

26 1000000
! 18006034
? 66957270
! 2133064
! 147618
! 34621442
? 49715575
? 62879287
! 18620682
? 67073751
! 62941186
! 7634532
? 67100031
? 12517237
! 4804997
? 65991126
! 138275
? 65722687
? 66043391
! 19147234
? 45743743
! 2242648
! 44378336
? 48226020
! 34341926
! 665045
? 55433083
! 5554254
? 4...

output:

0
0
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
0
0
0
1
1
0
1
1
1
0
1
1
1
0
1
0
1
1
0
0
0
0
1
1
0
0
1
0
1
0
0
1
0
1
1
0
1
1
0
0
1
0
1
0
1
0
1
1
1
1
0
0
1
0
0
0
0
1
0
1
0
1
1
0
0
1
0
1
1
0
0
0
1
0
1
1
0
1
1
1
0
1
0
1
0
0
0
1
1
0
1
1
0
1
1
1
0
1
...

result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #21:

score: 0
Time Limit Exceeded

input:

28 1000000
! 1081468
! 128476263
! 67930241
? 94304031
! 103698752
! 19982
! 198050624
? 249519591
? 71286719
? 255700799
! 103309888
! 819340
! 12852092
? 124739445
? 192734967
! 101320328
! 117594711
? 252032927
! 134267948
? 262940285
! 3155972
? 267876218
! 41984160
? 246413294
? 246824252
? 163...

output:

0
0
1
0
1
0
0
0
0
0
1
1
1
0
0
0
1
0
1
1
1
0
0
0
1
1
0
1
1
1
0
0
1
0
1
1
1
0
0
0
1
0
1
1
1
0
0
1
1
0
0
1
0
0
1
1
1
0
1
1
0
1
0
1
1
1
0
0
0
0
1
1
1
0
0
1
0
1
1
1
0
0
0
0
0
0
1
0
1
0
1
0
1
1
0
0
0
1
1
1
1
1
0
1
0
1
0
1
0
0
1
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
1
0
0
0
1
0
1
1
1
0
0
0
1
0
1
1
1
0
1
1
0
1
0
1
...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #31:

score: 0
Time Limit Exceeded

input:

30 1000000
! 33852274
? 1017904007
? 1046413001
! 151029382
? 466826079
? 250568375
! 6769874
! 2106474
? 536832803
? 209627867
! 167104971
? 1048372157
! 245380745
! 25174496
? 819646460
! 539548800
! 671358165
? 402955591
? 527753201
! 582494209
? 862862931
? 938974695
? 263672827
? 366968669
? 87...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
1
0
0
0
1
1
0
0
1
1
0
0
0
1
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
0
1
1
0
0
0
1
0
0
1
0
0
0
1
0
0
1
1
0
1
0
1
1
1
1
0
1
1
1
1
1
1
0
1
1
0
0
1
0
1
1
0
1
0
0
0
1
1
1
1
0
1
1
0
1
1
1
0
1
0
1
1
0
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
1
1
0
0
1
0
0
1
0
1
1
1
...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #41:

score: 0
Time Limit Exceeded

input:

32 1000000
! 2474971548
! 348268033
? 1055293046
? 3382525679
? 1805515707
? 3210332902
? 2805668987
? 4025974780
! 2217771280
! 176949664
! 4213841344
! 1477473321
? 3150869759
? 2127418041
! 1610631720
! 3624477314
! 2288149532
! 70909964
! 40117153
! 1343751456
? 3758095615
! 513059275
! 31956816...

output:

0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
1
0
0
1
1
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
0
0
1
0
1
0
0
0
1
1
0
1
0
1
0
0
1
1
1
0
1
1
0
1
0
0
0
0
1
0
1
1
1
0
0
0
0
0
1
0
0
0
1
0
1
1
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
1
1
0
1
0
0
1
1
1
0
0
1
1
1
1
1
1
1
...

result: