# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136268 | 2019-07-25T05:14:52 Z | 김현수(#3358) | Queue (CEOI06_queue) | C++14 | 912 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.find(I) == fr.end()) return I-1; return fr[I]; } int getbk (int I) { if(bk.find(I) == bk.end()) 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 | 256 KB | Output is correct |
2 | Runtime error | 496 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 506 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Correct | 5 ms | 504 KB | Output is correct |
5 | Correct | 32 ms | 1400 KB | Output is correct |
6 | Correct | 44 ms | 2364 KB | Output is correct |
7 | Correct | 65 ms | 3528 KB | Output is correct |
8 | Correct | 98 ms | 5596 KB | Output is correct |
9 | Correct | 101 ms | 5944 KB | Output is correct |
10 | Correct | 120 ms | 6608 KB | Output is correct |
11 | Correct | 302 ms | 14432 KB | Output is correct |
12 | Correct | 264 ms | 11784 KB | Output is correct |
13 | Correct | 324 ms | 14456 KB | Output is correct |
14 | Incorrect | 229 ms | 9440 KB | Output isn't correct |
15 | Incorrect | 258 ms | 10632 KB | Output isn't correct |
16 | Correct | 382 ms | 14488 KB | Output is correct |
17 | Runtime error | 517 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
18 | Incorrect | 52 ms | 1144 KB | Output isn't correct |
19 | Runtime error | 877 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Runtime error | 912 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
21 | Incorrect | 213 ms | 12276 KB | Output isn't correct |
22 | Correct | 331 ms | 16580 KB | Output is correct |
23 | Correct | 416 ms | 20040 KB | Output is correct |
24 | Incorrect | 342 ms | 16512 KB | Output isn't correct |
25 | Incorrect | 362 ms | 15840 KB | Output isn't correct |