# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136263 | 2019-07-25T05:11:58 Z | 김현수(#3358) | Queue (CEOI06_queue) | C++14 | 898 ms | 65540 KB |
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int,int> pii; const int N = 50005, inf = 1e9+7; map<int, int> fr, bk; set<pii> s[2]; int getfr (int I) { if(fr[I] == 0) return I-1; return fr[I]; } int getbk (int I) { if(bk[I] == 0) return I+1; return bk[I]; } int main() { int n, q; scanf("%d",&n); bk[inf] = inf; int CT = 1; while(n--) { int A, B; scanf("%d%d",&A,&B); if(A == B) continue; int AF = getfr(A), AB = getbk(A), BF = getfr(B); fr[AB] = AF; bk[AF] = AB; fr[A] = BF; bk[BF] = A; fr[B] = A; bk[A] = B; if(CT == B) CT = A; } for(int i=CT,j=1;i<inf;) { auto it = bk.lower_bound(i); int E = (*it).X; j += E-i; s[0].insert({E, j}); s[1].insert({j, E}); i = (*it).Y; j++; } scanf("%d",&q); while(q--) { char T[2]; int A; scanf("%s%d",T,&A); auto it = s[T[0]=='L'].lower_bound({A, 0}); printf("%d\n", (*it).Y - (*it).X + A); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 478 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 508 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 32 ms | 1400 KB | Output is correct |
6 | Correct | 44 ms | 2424 KB | Output is correct |
7 | Correct | 63 ms | 3448 KB | Output is correct |
8 | Correct | 96 ms | 5752 KB | Output is correct |
9 | Correct | 98 ms | 6104 KB | Output is correct |
10 | Correct | 109 ms | 6648 KB | Output is correct |
11 | Correct | 302 ms | 14460 KB | Output is correct |
12 | Correct | 260 ms | 11896 KB | Output is correct |
13 | Correct | 299 ms | 14572 KB | Output is correct |
14 | Incorrect | 217 ms | 9464 KB | Output isn't correct |
15 | Incorrect | 250 ms | 10576 KB | Output isn't correct |
16 | Correct | 314 ms | 14584 KB | Output is correct |
17 | Runtime error | 522 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
18 | Incorrect | 54 ms | 1132 KB | Output isn't correct |
19 | Runtime error | 898 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Runtime error | 845 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
21 | Incorrect | 203 ms | 12228 KB | Output isn't correct |
22 | Correct | 310 ms | 16620 KB | Output is correct |
23 | Correct | 445 ms | 20040 KB | Output is correct |
24 | Incorrect | 347 ms | 16524 KB | Output isn't correct |
25 | Incorrect | 370 ms | 15828 KB | Output isn't correct |