# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
136277 | 2019-07-25T05:28:56 Z | 김현수(#3358) | Queue (CEOI06_queue) | C++14 | 411 ms | 20220 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, 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); int AF = getfr(A), AB = getbk(A), BF = getfr(B); if(A == B || AB == B) continue; 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][E] = j; s[1][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); printf("%d\n", (*it).Y - (*it).X + A); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 32 ms | 1400 KB | Output is correct |
6 | Correct | 43 ms | 2440 KB | Output is correct |
7 | Correct | 76 ms | 3448 KB | Output is correct |
8 | Correct | 95 ms | 5624 KB | Output is correct |
9 | Correct | 101 ms | 6008 KB | Output is correct |
10 | Correct | 117 ms | 6568 KB | Output is correct |
11 | Correct | 305 ms | 14392 KB | Output is correct |
12 | Correct | 250 ms | 11932 KB | Output is correct |
13 | Correct | 411 ms | 14520 KB | Output is correct |
14 | Incorrect | 239 ms | 9520 KB | Output isn't correct |
15 | Incorrect | 265 ms | 10620 KB | Output isn't correct |
16 | Correct | 313 ms | 14628 KB | Output is correct |
17 | Correct | 29 ms | 632 KB | Output is correct |
18 | Incorrect | 51 ms | 1128 KB | Output isn't correct |
19 | Correct | 94 ms | 1812 KB | Output is correct |
20 | Incorrect | 140 ms | 1936 KB | Output isn't correct |
21 | Incorrect | 199 ms | 12252 KB | Output isn't correct |
22 | Correct | 321 ms | 16600 KB | Output is correct |
23 | Correct | 403 ms | 20220 KB | Output is correct |
24 | Incorrect | 363 ms | 16724 KB | Output isn't correct |
25 | Correct | 357 ms | 15868 KB | Output is correct |