# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
144266 | 2019-08-16T12:16:29 Z | SamAnd | Tenis (COI19_tenis) | C++17 | 500 ms | 6008 KB |
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct ban { int x, y, z; }; int n, q; ban a[N], b[N]; bool cx[N], cy[N], cz[N]; bool c[N]; int stg(int x) { int ans = 0; if (cx[x]) ++ans; if (cy[x]) ++ans; if (cz[x]) ++ans; return ans; } void bil() { memset(c, false, sizeof c); memset(cx, false, sizeof cx); memset(cy, false, sizeof cy); memset(cz, false, sizeof cz); int q = 0; int j = n + 1; for (int i = n; i > 1; --i) { cx[a[i].x] = true; if (stg(a[i].x) == 1) ++q; else if (stg(a[i].x) == 3) --q; cy[a[i].y] = true; if (stg(a[i].y) == 1) ++q; else if (stg(a[i].y) == 3) --q; cz[a[i].z] = true; if (stg(a[i].z) == 1) ++q; else if (stg(a[i].z) == 3) --q; if (q == 0) { j = i; } } for (int i = j; i <= n; ++i) { c[a[i].x] = true; } } int main() { scanf("%d%d", &n, &q); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].x); b[a[i].x].x = i; } for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].y); b[a[i].y].y = i; } for (int i = 1; i <= n; ++i) { scanf("%d", &a[i].z); b[a[i].z].z = i; } bil(); while (q--) { int ty; scanf("%d", &ty); if (ty == 1) { int x; scanf("%d", &x); if (c[x] == false) printf("DA\n"); else printf("NE\n"); } else { int p, x, y; scanf("%d%d%d", &p, &x, &y); if (p == 1) { swap(a[b[x].x].x, a[b[y].x].x); swap(b[x].x, b[y].x); } else if (p == 2) { swap(a[b[x].y].y, a[b[y].y].y); swap(b[x].y, b[y].y); } else { swap(a[b[x].z].z, a[b[y].z].z); swap(b[x].z, b[y].z); } bil(); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 760 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 3 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 760 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 3 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 73 ms | 3220 KB | Output is correct |
14 | Correct | 82 ms | 4728 KB | Output is correct |
15 | Correct | 90 ms | 4728 KB | Output is correct |
16 | Correct | 73 ms | 4728 KB | Output is correct |
17 | Correct | 61 ms | 4728 KB | Output is correct |
18 | Correct | 72 ms | 4856 KB | Output is correct |
19 | Correct | 65 ms | 4724 KB | Output is correct |
20 | Correct | 80 ms | 4728 KB | Output is correct |
21 | Correct | 120 ms | 4828 KB | Output is correct |
22 | Correct | 75 ms | 4856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 4060 KB | Output is correct |
2 | Correct | 87 ms | 5884 KB | Output is correct |
3 | Correct | 84 ms | 6008 KB | Output is correct |
4 | Correct | 85 ms | 5848 KB | Output is correct |
5 | Correct | 98 ms | 5852 KB | Output is correct |
6 | Correct | 86 ms | 5880 KB | Output is correct |
7 | Correct | 89 ms | 5852 KB | Output is correct |
8 | Correct | 84 ms | 5880 KB | Output is correct |
9 | Correct | 85 ms | 5924 KB | Output is correct |
10 | Correct | 82 ms | 5844 KB | Output is correct |
11 | Correct | 84 ms | 5880 KB | Output is correct |
12 | Correct | 85 ms | 5880 KB | Output is correct |
13 | Correct | 88 ms | 5928 KB | Output is correct |
14 | Correct | 86 ms | 5880 KB | Output is correct |
15 | Correct | 88 ms | 5756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 760 KB | Output is correct |
6 | Correct | 2 ms | 760 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 3 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 73 ms | 3220 KB | Output is correct |
14 | Correct | 82 ms | 4728 KB | Output is correct |
15 | Correct | 90 ms | 4728 KB | Output is correct |
16 | Correct | 73 ms | 4728 KB | Output is correct |
17 | Correct | 61 ms | 4728 KB | Output is correct |
18 | Correct | 72 ms | 4856 KB | Output is correct |
19 | Correct | 65 ms | 4724 KB | Output is correct |
20 | Correct | 80 ms | 4728 KB | Output is correct |
21 | Correct | 120 ms | 4828 KB | Output is correct |
22 | Correct | 75 ms | 4856 KB | Output is correct |
23 | Correct | 85 ms | 4060 KB | Output is correct |
24 | Correct | 87 ms | 5884 KB | Output is correct |
25 | Correct | 84 ms | 6008 KB | Output is correct |
26 | Correct | 85 ms | 5848 KB | Output is correct |
27 | Correct | 98 ms | 5852 KB | Output is correct |
28 | Correct | 86 ms | 5880 KB | Output is correct |
29 | Correct | 89 ms | 5852 KB | Output is correct |
30 | Correct | 84 ms | 5880 KB | Output is correct |
31 | Correct | 85 ms | 5924 KB | Output is correct |
32 | Correct | 82 ms | 5844 KB | Output is correct |
33 | Correct | 84 ms | 5880 KB | Output is correct |
34 | Correct | 85 ms | 5880 KB | Output is correct |
35 | Correct | 88 ms | 5928 KB | Output is correct |
36 | Correct | 86 ms | 5880 KB | Output is correct |
37 | Correct | 88 ms | 5756 KB | Output is correct |
38 | Execution timed out | 1056 ms | 5008 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |