# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117776 | 2019-06-17T07:50:54 Z | 이온조(#2879) | Tenis (COI19_tenis) | C++14 | 175 ms | 5428 KB |
#include <bits/stdc++.h> using namespace std; using tiii = tuple<int, int, int>; const int MXN = 100009; struct player { int id, x, y, z; } A[MXN]; int X[MXN], Y[MXN], Z[MXN]; int yl[MXN], yr[MXN], zl[MXN], zr[MXN]; int Ri[MXN]; int main() { int N, Q; scanf("%d%d",&N,&Q); for(int i=1; i<=N; i++) {scanf("%d",&X[i]); A[X[i]].x = i;} for(int i=1; i<=N; i++) {scanf("%d",&Y[i]); A[Y[i]].y = i;} for(int i=1; i<=N; i++) {scanf("%d",&Z[i]); A[Z[i]].z = i;} for(int i=1; i<=N; i++) A[i].id = i; sort(A+1, A+N+1, [&](player P, player Q) {return P.x < Q.x;}); yr[N+1] = 1e9, zr[N+1] = 1e9; for(int i=1; i<=N; i++) yl[i] = max(yl[i-1], A[i].y), zl[i] = max(zl[i-1], A[i].z); for(int i=N; i>=1; i--) yr[i] = min(yr[i+1], A[i].y), zr[i] = min(zr[i+1], A[i].z); int l = N; for(int i=1; i<N; i++) if(yl[i] < yr[i+1] && zl[i] < zr[i+1]) {l = i; break;} for(int i=1; i<=N; i++) Ri[A[i].id] = A[i].x; while(Q--) { int ty; scanf("%d", &ty); if(ty == 1) { int X; scanf("%d", &X); if(Ri[X] <= l) puts("DA"); else puts("NE"); } if(ty == 2) { int P, a, b; scanf("%d%d%d",&P,&a,&b); a = Ri[a], b = Ri[b]; if(P == 1) swap(Ri[a], Ri[b]); if(P == 2) swap(A[a].y, A[b].y); if(P == 3) swap(A[a].z, A[b].z); yr[N+1] = 1e9, zr[N+1] = 1e9; for(int i=1; i<=N; i++) yl[i] = max(yl[i-1], A[i].y), zl[i] = max(zl[i-1], A[i].z); for(int i=N; i>=1; i--) yr[i] = min(yr[i+1], A[i].y), zr[i] = min(zr[i+1], A[i].z); l = N; for(int i=1; i<N; i++) if(yl[i] < yr[i+1] && zl[i] < zr[i+1]) {l = i; break;} } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Incorrect | 2 ms | 384 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Incorrect | 2 ms | 384 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 5244 KB | Output is correct |
2 | Correct | 82 ms | 5240 KB | Output is correct |
3 | Correct | 93 ms | 5408 KB | Output is correct |
4 | Correct | 84 ms | 5240 KB | Output is correct |
5 | Correct | 89 ms | 5368 KB | Output is correct |
6 | Correct | 82 ms | 5428 KB | Output is correct |
7 | Correct | 88 ms | 5340 KB | Output is correct |
8 | Correct | 91 ms | 5296 KB | Output is correct |
9 | Correct | 93 ms | 5368 KB | Output is correct |
10 | Correct | 89 ms | 5272 KB | Output is correct |
11 | Correct | 91 ms | 5300 KB | Output is correct |
12 | Correct | 93 ms | 5328 KB | Output is correct |
13 | Correct | 93 ms | 5368 KB | Output is correct |
14 | Correct | 175 ms | 5348 KB | Output is correct |
15 | Correct | 168 ms | 5368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Incorrect | 2 ms | 384 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |