# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44296 | 2018-03-31T10:06:41 Z | ssnsarang2023 | Zagonetka (COI18_zagonetka) | C++17 | 14 ms | 380 KB |
#define debug #include <cstdio> #include <iostream> #include <algorithm> #include <functional> #include <vector> #include <cstring> #include <cmath> #include <queue> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; #define SZ(x) ((int)x.size()) const int N = 105; int n, a[N], pos_small[N], pos_large[N]; int small[N], large[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); small[i] = large[i] = a[i]; pos_small[a[i]] = pos_large[a[i]] = i; } for (int i = 1; i <= n; ++i) { for (int j = 1; j < pos_small[i]; ++j) { if (small[j] > i) { int idx = pos_small[i]; int tmp = small[idx]; small[idx] = small[j]; small[j] = tmp; printf("query "); for (int k = 1; k <= n; ++k) { printf("%d ", small[k]); } fflush(stdout); int re = 0; scanf("%d", &re); if (re == 1) { pos_small[small[idx]] = idx; break; } else { int tmp = small[idx]; small[idx] = small[j]; small[j] = tmp; } } } } for (int i = n; i >= 1; --i) { for (int j = 1; j < pos_large[i]; ++j) { if (large[j] < i) { int idx = pos_large[i]; int tmp = large[idx]; large[idx] = large[j]; large[j] = tmp; printf("query "); for (int k = 1; k <= n; ++k) { printf("%d ", large[k]); } fflush(stdout); int re = 0; scanf("%d", &re); if (re == 1) { pos_large[large[idx]] = idx; break; } else { int tmp = large[idx]; large[idx] = large[j]; large[j] = tmp; } } } } printf("end\n"); for (int i = 1; i <= n; ++i) { printf("%d ", small[i]); } puts(""); for (int i = 1; i <= n; ++i) { printf("%d ", large[i]); } fflush(stdout); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 308 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 14 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |