# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
570620 | 2022-05-30T18:20:14 Z | patrikpavic2 | Zagonetka (COI18_zagonetka) | C++17 | 108 ms | 416 KB |
#include <cstdio> #include <vector> #include <algorithm> #define PB push_back #define X first #define Y second using namespace std; typedef pair < int, int > pii; const int N = 5050; int p[N], q[N], l[N], r[N], uz[N], n; bool pitaj(){ printf("query "); for(int i = 0;i < n;i++) printf("%d ", q[i]); printf("\n"); fflush(stdout); int x; scanf("%d", &x); return x; } int main(){ scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d", p + i); q[i] = p[i]; } for(int i = 0;i < n;i++){ for(int j = q[i] - 1;j >= 1;j--){ if(uz[j]) continue; vector < pii > vr; for(int k = i;k < n;k++){ if(q[k] <= q[i] && q[k] >= j) vr.PB({q[k], k}); } sort(vr.begin(), vr.end()); for(int i = 0;i + 1 < (int)vr.size();i++){ q[vr[i + 1].Y] = vr[i].X; } q[vr[0].Y] = vr.back().X; if(!pitaj()){ for(pii &tmp : vr) q[tmp.Y] = tmp.X; } } uz[q[i]] = 1; } for(int i = 0;i < n;i++){ l[i] = q[i]; q[i] = p[i]; uz[i + 1] = 0; } for(int i = 0;i < n;i++){ for(int j = q[i] + 1;j <= n;j++){ if(uz[j]) continue; vector < pii > vr; for(int k = i;k < n;k++){ if(q[k] >= q[i] && q[k] <= j) vr.PB({q[k], k}); } sort(vr.begin(), vr.end()); for(int i = 0;i + 1 < (int)vr.size();i++){ q[vr[i].Y] = vr[i + 1].X; } q[vr.back().Y] = vr[0].X; if(!pitaj()){ for(pii &tmp : vr) q[tmp.Y] = tmp.X; } } uz[q[i]] = 1; } printf("end\n"); for(int i = 0;i < n;i++) printf("%d ", l[i]); printf("\n"); for(int i = 0;i < n;i++) printf("%d ", q[i]); printf("\n"); fflush(stdout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 284 KB | Output is correct |
2 | Correct | 1 ms | 208 KB | Output is correct |
3 | Correct | 0 ms | 208 KB | Output is correct |
4 | Correct | 1 ms | 208 KB | Output is correct |
5 | Correct | 1 ms | 208 KB | Output is correct |
6 | Correct | 1 ms | 208 KB | Output is correct |
7 | Correct | 1 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 304 KB | Output is correct |
2 | Correct | 28 ms | 208 KB | Output is correct |
3 | Correct | 33 ms | 296 KB | Output is correct |
4 | Correct | 32 ms | 288 KB | Output is correct |
5 | Correct | 14 ms | 284 KB | Output is correct |
6 | Correct | 44 ms | 284 KB | Output is correct |
7 | Correct | 5 ms | 208 KB | Output is correct |
8 | Correct | 7 ms | 208 KB | Output is correct |
9 | Correct | 36 ms | 296 KB | Output is correct |
10 | Correct | 15 ms | 288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 3 ms | 208 KB | Output is correct |
3 | Correct | 6 ms | 208 KB | Output is correct |
4 | Correct | 6 ms | 208 KB | Output is correct |
5 | Correct | 4 ms | 208 KB | Output is correct |
6 | Correct | 8 ms | 312 KB | Output is correct |
7 | Correct | 4 ms | 208 KB | Output is correct |
8 | Correct | 5 ms | 208 KB | Output is correct |
9 | Correct | 5 ms | 208 KB | Output is correct |
10 | Correct | 3 ms | 208 KB | Output is correct |
11 | Correct | 5 ms | 208 KB | Output is correct |
12 | Correct | 6 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 288 KB | Output is correct |
2 | Correct | 98 ms | 284 KB | Output is correct |
3 | Correct | 76 ms | 284 KB | Output is correct |
4 | Correct | 58 ms | 416 KB | Output is correct |
5 | Correct | 108 ms | 296 KB | Output is correct |
6 | Correct | 102 ms | 288 KB | Output is correct |
7 | Correct | 72 ms | 296 KB | Output is correct |
8 | Correct | 78 ms | 308 KB | Output is correct |
9 | Correct | 82 ms | 308 KB | Output is correct |
10 | Correct | 68 ms | 328 KB | Output is correct |
11 | Correct | 83 ms | 208 KB | Output is correct |
12 | Correct | 78 ms | 208 KB | Output is correct |
13 | Correct | 80 ms | 288 KB | Output is correct |
14 | Correct | 77 ms | 208 KB | Output is correct |
15 | Correct | 102 ms | 288 KB | Output is correct |
16 | Correct | 95 ms | 312 KB | Output is correct |