# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
136253 | 2019-07-25T05:07:49 Z | 김현수(#3358) | Queue (CEOI06_queue) | C++14 | 854 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); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Runtime error | 481 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
3 | Runtime error | 510 ms | 65536 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 | 1308 KB | Output is correct |
6 | Correct | 44 ms | 2424 KB | Output is correct |
7 | Correct | 63 ms | 3468 KB | Output is correct |
8 | Correct | 92 ms | 5752 KB | Output is correct |
9 | Correct | 101 ms | 6008 KB | Output is correct |
10 | Correct | 110 ms | 6620 KB | Output is correct |
11 | Correct | 294 ms | 14368 KB | Output is correct |
12 | Correct | 265 ms | 11896 KB | Output is correct |
13 | Correct | 298 ms | 14492 KB | Output is correct |
14 | Incorrect | 227 ms | 9496 KB | Output isn't correct |
15 | Incorrect | 249 ms | 10592 KB | Output isn't correct |
16 | Correct | 300 ms | 14456 KB | Output is correct |
17 | Runtime error | 509 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
18 | Incorrect | 53 ms | 1144 KB | Output isn't correct |
19 | Runtime error | 854 ms | 65536 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
20 | Runtime error | 827 ms | 65540 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
21 | Incorrect | 199 ms | 12152 KB | Output isn't correct |
22 | Correct | 310 ms | 16632 KB | Output is correct |
23 | Correct | 451 ms | 20088 KB | Output is correct |
24 | Incorrect | 335 ms | 16560 KB | Output isn't correct |
25 | Incorrect | 367 ms | 15980 KB | Output isn't correct |