# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211905 | 2020-03-21T16:24:57 Z | mieszko11b | Chameleon's Love (JOI20_chameleon) | C++14 | 73 ms | 512 KB |
#include "chameleon.h" #include <vector> #include <bits/stdc++.h> using namespace std; namespace { int cnt = 0; vector<int> A[4]; vector<int> E[1007]; int nxt[1007], prv[1007]; } // namespace bool check(int i, int a, int b, int w) { vector<int> V(b - a + 1); for(int j = a ; j <= b ; j++) V[j - a] = A[i][j]; V.push_back(w); return Query(V) != V.size(); } void Solve(int n) { n *= 2; for(int i = 1 ; i <= n ; i++) { int firstok = -1; for(int j = 0 ; j < cnt ; j++) { int ind = 0; bool ok = true; while(ind < A[j].size() && check(j, ind, A[j].size() - 1, i)) { ok = false; int pocz = ind, kon = A[j].size() - 1, mid; while(pocz < kon) { mid = (pocz + kon) / 2; if(check(j, ind, mid, i)) kon = mid; else pocz = mid + 1; } E[i].push_back(A[j][pocz]); E[A[j][pocz]].push_back(i); //~ cout << "E " << i << " " << A[j][pocz] << endl; ind = pocz + 1; } if(ok && firstok == -1) firstok = j; } if(firstok == -1) { firstok = cnt++; } A[firstok].push_back(i); } //~ for(int i = 1 ; i <= n ; i++) { //~ cout << i << ": "; //~ for(int j : E[i]) //~ cout << j << " "; //~ cout << endl; //~ } for(int i = 1 ; i <= n ; i++) { if(E[i].size() == 3) { if(Query({i, E[i][0], E[i][1]}) == 1) { nxt[i] = E[i][2]; //~ prv[E[i][2]] = i; } else if(Query({i, E[i][0], E[i][2]}) == 1) { nxt[i] = E[i][1]; //~ prv[E[i][1]] = i; } else { nxt[i] = E[i][0]; //~ prv[E[i][0]] = i; } } } for(int i = 1 ; i <= n ; i++) { int ans; for(int x : E[i]) if(x != nxt[i] && nxt[x] != i) ans = x; if(ans > i) Answer(i, ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 32 ms | 384 KB | Output is correct |
4 | Correct | 36 ms | 384 KB | Output is correct |
5 | Correct | 32 ms | 460 KB | Output is correct |
6 | Correct | 35 ms | 384 KB | Output is correct |
7 | Correct | 33 ms | 384 KB | Output is correct |
8 | Correct | 32 ms | 384 KB | Output is correct |
9 | Correct | 32 ms | 420 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 304 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 304 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 6 ms | 384 KB | Output is correct |
13 | Correct | 6 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 6 ms | 384 KB | Output is correct |
16 | Correct | 6 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 50 ms | 440 KB | Output is correct |
4 | Correct | 59 ms | 480 KB | Output is correct |
5 | Correct | 56 ms | 384 KB | Output is correct |
6 | Correct | 52 ms | 448 KB | Output is correct |
7 | Correct | 60 ms | 428 KB | Output is correct |
8 | Correct | 62 ms | 452 KB | Output is correct |
9 | Correct | 69 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 32 ms | 384 KB | Output is correct |
4 | Correct | 36 ms | 384 KB | Output is correct |
5 | Correct | 32 ms | 460 KB | Output is correct |
6 | Correct | 35 ms | 384 KB | Output is correct |
7 | Correct | 33 ms | 384 KB | Output is correct |
8 | Correct | 32 ms | 384 KB | Output is correct |
9 | Correct | 32 ms | 420 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 304 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 5 ms | 384 KB | Output is correct |
21 | Correct | 6 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 384 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 6 ms | 384 KB | Output is correct |
25 | Correct | 6 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 5 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 50 ms | 440 KB | Output is correct |
31 | Correct | 59 ms | 480 KB | Output is correct |
32 | Correct | 56 ms | 384 KB | Output is correct |
33 | Correct | 52 ms | 448 KB | Output is correct |
34 | Correct | 60 ms | 428 KB | Output is correct |
35 | Correct | 62 ms | 452 KB | Output is correct |
36 | Correct | 69 ms | 384 KB | Output is correct |
37 | Correct | 51 ms | 432 KB | Output is correct |
38 | Correct | 40 ms | 416 KB | Output is correct |
39 | Correct | 69 ms | 384 KB | Output is correct |
40 | Correct | 69 ms | 456 KB | Output is correct |
41 | Correct | 73 ms | 420 KB | Output is correct |
42 | Correct | 31 ms | 384 KB | Output is correct |
43 | Correct | 52 ms | 384 KB | Output is correct |
44 | Correct | 50 ms | 384 KB | Output is correct |
45 | Correct | 67 ms | 512 KB | Output is correct |