#include "minerals.h"
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
bitset<90000> on;
int uwusgi(int x) {
on.flip(x);
return Query(x);
}
#define Query uwusgi
void Solve(int N) {
vector<int> A, B, C(N), V;
{
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> ord(2*N);
iota(all(ord), 1);
shuffle(all(ord), rng);
int lst = 0;
for(auto i : ord) {
int cc = Query(i);
if(cc == lst) {
V.push_back(A.size());
}
(cc==lst ? B : A).push_back(i);
lst = cc;
}
}
// int CC = 0;
for(int b = 0; b < 16; b++) {
int lst = 0;
for(int i = 0; i < N; i++)
if(((i>>b)&1)^on[A[i]])
lst = Query(A[i]);
vector<int> cnt(1<<16), cnto(1<<16);
for(auto i : C) cnt[i]++;
for(int i = 0; i < 1<<b; i++) {
for(int j = 0; j < 1<<(16-b); j++) {
int c = i | (j<<b);
if(c<N)
cnto[i] += j&1;
}
}
for(int i = 0; i < N; i++) {
if((C[i]|(1<<b)) > V[i] || !cnto[C[i]]) {cnt[C[i]]--;continue;}
if(cnto[C[i]]) {
int qq = -1;
if(cnto[C[i]] == cnt[C[i]] && lst != qq) qq = lst;//cout << "HEY"<<endl;
else qq = Query(B[i]);
if(lst == qq) cnto[C[i]]--;
C[i] |= (lst == qq)<<b;
lst = qq;
} else {
C[i] |= cnto[C[i]]<<b;
cnto[C[i]]--;
}
cnt[C[i]]--;
}
// for(auto i : C) cout << i << " "; cout << endl;
}
for(int i = 0; i < N; i++)
Answer(A[C[i]], B[i]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
960 KB |
Output is correct |
2 |
Correct |
4 ms |
928 KB |
Output is correct |
3 |
Correct |
8 ms |
1024 KB |
Output is correct |
4 |
Correct |
9 ms |
1220 KB |
Output is correct |
5 |
Correct |
16 ms |
1580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
19 |
Correct |
49 ms |
2380 KB |
Output is correct |
20 |
Correct |
44 ms |
2372 KB |
Output is correct |
21 |
Correct |
42 ms |
2372 KB |
Output is correct |
22 |
Correct |
41 ms |
2240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
19 |
Correct |
49 ms |
2380 KB |
Output is correct |
20 |
Correct |
44 ms |
2372 KB |
Output is correct |
21 |
Correct |
42 ms |
2372 KB |
Output is correct |
22 |
Correct |
41 ms |
2240 KB |
Output is correct |
23 |
Correct |
44 ms |
2396 KB |
Output is correct |
24 |
Correct |
49 ms |
2484 KB |
Output is correct |
25 |
Correct |
54 ms |
2436 KB |
Output is correct |
26 |
Correct |
43 ms |
2324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
19 |
Correct |
49 ms |
2380 KB |
Output is correct |
20 |
Correct |
44 ms |
2372 KB |
Output is correct |
21 |
Correct |
42 ms |
2372 KB |
Output is correct |
22 |
Correct |
41 ms |
2240 KB |
Output is correct |
23 |
Correct |
44 ms |
2396 KB |
Output is correct |
24 |
Correct |
49 ms |
2484 KB |
Output is correct |
25 |
Correct |
54 ms |
2436 KB |
Output is correct |
26 |
Correct |
43 ms |
2324 KB |
Output is correct |
27 |
Correct |
46 ms |
2736 KB |
Output is correct |
28 |
Correct |
50 ms |
2692 KB |
Output is correct |
29 |
Correct |
44 ms |
2732 KB |
Output is correct |
30 |
Correct |
51 ms |
2540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
19 |
Correct |
49 ms |
2380 KB |
Output is correct |
20 |
Correct |
44 ms |
2372 KB |
Output is correct |
21 |
Correct |
42 ms |
2372 KB |
Output is correct |
22 |
Correct |
41 ms |
2240 KB |
Output is correct |
23 |
Correct |
44 ms |
2396 KB |
Output is correct |
24 |
Correct |
49 ms |
2484 KB |
Output is correct |
25 |
Correct |
54 ms |
2436 KB |
Output is correct |
26 |
Correct |
43 ms |
2324 KB |
Output is correct |
27 |
Correct |
46 ms |
2736 KB |
Output is correct |
28 |
Correct |
50 ms |
2692 KB |
Output is correct |
29 |
Correct |
44 ms |
2732 KB |
Output is correct |
30 |
Correct |
51 ms |
2540 KB |
Output is correct |
31 |
Incorrect |
44 ms |
2500 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
788 KB |
Output is correct |
2 |
Correct |
3 ms |
824 KB |
Output is correct |
3 |
Correct |
3 ms |
840 KB |
Output is correct |
4 |
Correct |
4 ms |
832 KB |
Output is correct |
5 |
Correct |
4 ms |
960 KB |
Output is correct |
6 |
Correct |
4 ms |
928 KB |
Output is correct |
7 |
Correct |
8 ms |
1024 KB |
Output is correct |
8 |
Correct |
9 ms |
1220 KB |
Output is correct |
9 |
Correct |
16 ms |
1580 KB |
Output is correct |
10 |
Correct |
4 ms |
840 KB |
Output is correct |
11 |
Correct |
10 ms |
1352 KB |
Output is correct |
12 |
Correct |
15 ms |
1648 KB |
Output is correct |
13 |
Correct |
16 ms |
1628 KB |
Output is correct |
14 |
Correct |
16 ms |
1584 KB |
Output is correct |
15 |
Correct |
41 ms |
2392 KB |
Output is correct |
16 |
Correct |
45 ms |
2380 KB |
Output is correct |
17 |
Correct |
41 ms |
2412 KB |
Output is correct |
18 |
Correct |
44 ms |
2248 KB |
Output is correct |
19 |
Correct |
49 ms |
2380 KB |
Output is correct |
20 |
Correct |
44 ms |
2372 KB |
Output is correct |
21 |
Correct |
42 ms |
2372 KB |
Output is correct |
22 |
Correct |
41 ms |
2240 KB |
Output is correct |
23 |
Correct |
44 ms |
2396 KB |
Output is correct |
24 |
Correct |
49 ms |
2484 KB |
Output is correct |
25 |
Correct |
54 ms |
2436 KB |
Output is correct |
26 |
Correct |
43 ms |
2324 KB |
Output is correct |
27 |
Correct |
46 ms |
2736 KB |
Output is correct |
28 |
Correct |
50 ms |
2692 KB |
Output is correct |
29 |
Correct |
44 ms |
2732 KB |
Output is correct |
30 |
Correct |
51 ms |
2540 KB |
Output is correct |
31 |
Incorrect |
44 ms |
2500 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |