# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
858110 | 2023-10-07T12:13:21 Z | lovrot | The Collection Game (BOI21_swaps) | C++17 | 4 ms | 1440 KB |
#include "swaps.h" #include <cstdio> #include <algorithm> #include <vector> #include <cassert> #define EB emplace_back #define X first #define Y second #define MP make_pair using namespace std; typedef pair<int, int> pii; void solve(int n, int v) { int m = 1; vector<int> ANS; for(; m < n; m <<= 1) {} for(int i = 0; i < m; ++i) ANS.EB(i + 1); for(int i = 1 << 1; i <= m; i <<= 1) for(int j = i >> 1; j; j >>= 1) { vector<pii> S; for(int k = 0; k < m; ++k) { int _k = k, l = k ^ j; if(l > _k) { if(_k & i) swap(l, _k); S.EB(MP(_k, l)); if(ANS[_k] <= n && ANS[l] <= n) schedule(ANS[_k], ANS[l]); } } vector<int> RES = visit(); for(int k = 0, cnt = 0; k < S.size(); ++k) { int a = S[k].X, b = S[k].Y; if(ANS[a] <= n && ANS[b] <= n) { if(!RES[cnt]) swap(ANS[a], ANS[b]); ++cnt; } else if(ANS[a] > n && ANS[b] <= n) { swap(ANS[a], ANS[b]); } } S.clear(); } for(int i = 0; i < m - n; ++i) ANS.pop_back(); answer(ANS); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 420 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 684 KB | Correct |
5 | Correct | 3 ms | 932 KB | Correct |
6 | Correct | 3 ms | 848 KB | Correct |
7 | Correct | 3 ms | 688 KB | Correct |
8 | Correct | 3 ms | 684 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 424 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 684 KB | Correct |
5 | Correct | 3 ms | 680 KB | Correct |
6 | Correct | 3 ms | 680 KB | Correct |
7 | Correct | 3 ms | 1188 KB | Correct |
8 | Correct | 3 ms | 684 KB | Correct |
9 | Correct | 3 ms | 688 KB | Correct |
10 | Correct | 3 ms | 936 KB | Correct |
11 | Correct | 3 ms | 428 KB | Correct |
12 | Correct | 3 ms | 432 KB | Correct |
13 | Correct | 3 ms | 688 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 424 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 424 KB | Correct |
3 | Correct | 0 ms | 344 KB | Correct |
4 | Correct | 1 ms | 424 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 600 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 1180 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 600 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 1180 KB | Correct |
5 | Correct | 0 ms | 344 KB | Correct |
6 | Correct | 1 ms | 420 KB | Correct |
7 | Correct | 1 ms | 344 KB | Correct |
8 | Correct | 3 ms | 944 KB | Correct |
9 | Correct | 3 ms | 936 KB | Correct |
10 | Correct | 3 ms | 1440 KB | Correct |
11 | Correct | 3 ms | 684 KB | Correct |
12 | Correct | 3 ms | 432 KB | Correct |
13 | Correct | 0 ms | 344 KB | Correct |
14 | Correct | 1 ms | 600 KB | Correct |
15 | Correct | 2 ms | 344 KB | Correct |
16 | Correct | 4 ms | 936 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 428 KB | Correct |
3 | Correct | 2 ms | 344 KB | Correct |
4 | Correct | 3 ms | 680 KB | Correct |
5 | Correct | 3 ms | 596 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 428 KB | Correct |
3 | Correct | 2 ms | 344 KB | Correct |
4 | Correct | 3 ms | 680 KB | Correct |
5 | Correct | 3 ms | 596 KB | Correct |
6 | Correct | 1 ms | 344 KB | Correct |
7 | Correct | 1 ms | 424 KB | Correct |
8 | Correct | 2 ms | 344 KB | Correct |
9 | Correct | 3 ms | 1180 KB | Correct |
10 | Correct | 3 ms | 936 KB | Correct |
11 | Correct | 3 ms | 688 KB | Correct |
12 | Correct | 3 ms | 680 KB | Correct |
13 | Correct | 3 ms | 428 KB | Correct |
14 | Correct | 3 ms | 932 KB | Correct |
15 | Correct | 4 ms | 684 KB | Correct |
16 | Correct | 3 ms | 688 KB | Correct |
17 | Correct | 3 ms | 432 KB | Correct |
18 | Correct | 3 ms | 1192 KB | Correct |
19 | Correct | 0 ms | 344 KB | Correct |
20 | Correct | 1 ms | 416 KB | Correct |
21 | Correct | 1 ms | 596 KB | Correct |
22 | Correct | 3 ms | 932 KB | Correct |
23 | Correct | 3 ms | 432 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 344 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 684 KB | Correct |
5 | Correct | 4 ms | 684 KB | Correct |
6 | Correct | 3 ms | 680 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 344 KB | Correct |
3 | Correct | 1 ms | 344 KB | Correct |
4 | Correct | 3 ms | 684 KB | Correct |
5 | Correct | 4 ms | 684 KB | Correct |
6 | Correct | 3 ms | 680 KB | Correct |
7 | Correct | 0 ms | 344 KB | Correct |
8 | Correct | 1 ms | 420 KB | Correct |
9 | Correct | 2 ms | 344 KB | Correct |
10 | Correct | 3 ms | 936 KB | Correct |
11 | Correct | 3 ms | 432 KB | Correct |
12 | Correct | 3 ms | 680 KB | Correct |
13 | Correct | 3 ms | 428 KB | Correct |
14 | Correct | 3 ms | 428 KB | Correct |
15 | Correct | 3 ms | 684 KB | Correct |
16 | Correct | 3 ms | 436 KB | Correct |
17 | Correct | 3 ms | 676 KB | Correct |
18 | Correct | 3 ms | 676 KB | Correct |
19 | Correct | 3 ms | 432 KB | Correct |
20 | Correct | 0 ms | 344 KB | Correct |
21 | Correct | 1 ms | 420 KB | Correct |
22 | Correct | 1 ms | 344 KB | Correct |
23 | Correct | 3 ms | 684 KB | Correct |
24 | Correct | 4 ms | 1180 KB | Correct |
25 | Correct | 3 ms | 408 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 424 KB | Correct |
3 | Correct | 2 ms | 344 KB | Correct |
4 | Correct | 3 ms | 432 KB | Correct |
5 | Correct | 3 ms | 684 KB | Correct |
6 | Correct | 4 ms | 408 KB | Correct |
7 | Correct | 3 ms | 1036 KB | Correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Correct |
2 | Correct | 1 ms | 424 KB | Correct |
3 | Correct | 2 ms | 344 KB | Correct |
4 | Correct | 3 ms | 432 KB | Correct |
5 | Correct | 3 ms | 684 KB | Correct |
6 | Correct | 4 ms | 408 KB | Correct |
7 | Correct | 3 ms | 1036 KB | Correct |
8 | Correct | 0 ms | 344 KB | Correct |
9 | Correct | 0 ms | 344 KB | Correct |
10 | Correct | 1 ms | 424 KB | Correct |
11 | Correct | 2 ms | 344 KB | Correct |
12 | Correct | 3 ms | 932 KB | Correct |
13 | Correct | 3 ms | 428 KB | Correct |
14 | Correct | 3 ms | 432 KB | Correct |
15 | Correct | 3 ms | 432 KB | Correct |
16 | Correct | 3 ms | 684 KB | Correct |
17 | Correct | 3 ms | 436 KB | Correct |
18 | Correct | 3 ms | 432 KB | Correct |
19 | Correct | 3 ms | 680 KB | Correct |
20 | Correct | 3 ms | 428 KB | Correct |
21 | Correct | 3 ms | 428 KB | Correct |
22 | Correct | 0 ms | 344 KB | Correct |
23 | Correct | 1 ms | 428 KB | Correct |
24 | Correct | 2 ms | 344 KB | Correct |
25 | Correct | 3 ms | 684 KB | Correct |
26 | Correct | 3 ms | 676 KB | Correct |
27 | Correct | 3 ms | 408 KB | Correct |
28 | Correct | 3 ms | 728 KB | Correct |