# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
29570 | 2017-07-20T06:43:38 Z | 서규호(#1242) | Lollipop (POI11_liz) | C++14 | 719 ms | 18620 KB |
#include <bits/stdc++.h> #include <unistd.h> #define pii pair<int,int> #define pll pair<lld,lld> #define pb push_back #define next nextt #define left leftt #define right rightt #define lld long long #define Inf 1000000000 #define Mod 1000000007 #define Linf 1000000000000000000LL #define get gett using namespace std; int N,M,sum; int s[2000002],e[2000002]; char a[1000002]; void process(int sum){ for(int i=sum-2; i>=1; i-=2){ if(a[s[i+2]-1] == 'T'){ s[i] = s[i+2]+1; e[i] = e[i+2]; }else if(a[e[i+2]-1] == 'T'){ s[i] = s[i+2]; e[i] = e[i+2]-1; }else{ s[i] = s[i+2]+1; e[i] = e[i+2]-1; } } } int main(){ //freopen("input.txt","r",stdin); scanf("%d %d",&N,&M); scanf("%s",a); int it = -1,it2; for(int i=0; i<N; i++){ if(a[i] == 'W'){ it = i; break; } } for(int i=N-1; i>=0; i--){ if(a[i] == 'W'){ it2 = i; break; } } for(int i=0; i<N; i++){ if(a[i] == 'W') sum++; else sum += 2; } if(it != -1){ s[sum] = 1; e[sum] = N; process(sum); if(it >= N-1-it2){ sum--; sum -= (N-1-it2)*2; s[sum] = 1; e[sum] = it2; }else{ sum--; sum -= (it*2); s[sum] = it+2; e[sum] = N; } process(sum); } for(int i=1; i<=M; i++){ int x; scanf("%d",&x); if(it == -1){ if(x%2 == 0 && x <= N*2) printf("1 %d\n",x/2); else puts("NIE"); }else{ if(s[x] == 0) puts("NIE"); else printf("%d %d\n",s[x],e[x]); } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18620 KB | Output is correct |
2 | Correct | 0 ms | 18620 KB | Output is correct |
3 | Correct | 0 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18620 KB | Output is correct |
2 | Correct | 0 ms | 18620 KB | Output is correct |
3 | Correct | 0 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18620 KB | Output is correct |
2 | Correct | 0 ms | 18620 KB | Output is correct |
3 | Correct | 3 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 18620 KB | Output is correct |
2 | Correct | 3 ms | 18620 KB | Output is correct |
3 | Correct | 3 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 18620 KB | Output is correct |
2 | Correct | 9 ms | 18620 KB | Output is correct |
3 | Correct | 33 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 18620 KB | Output is correct |
2 | Correct | 169 ms | 18620 KB | Output is correct |
3 | Correct | 73 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 18620 KB | Output is correct |
2 | Correct | 39 ms | 18620 KB | Output is correct |
3 | Correct | 83 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 179 ms | 18620 KB | Output is correct |
2 | Correct | 106 ms | 18620 KB | Output is correct |
3 | Correct | 189 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 373 ms | 18620 KB | Output is correct |
2 | Correct | 336 ms | 18620 KB | Output is correct |
3 | Correct | 369 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 243 ms | 18620 KB | Output is correct |
2 | Correct | 419 ms | 18620 KB | Output is correct |
3 | Correct | 446 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 709 ms | 18620 KB | Output is correct |
2 | Correct | 569 ms | 18620 KB | Output is correct |
3 | Correct | 563 ms | 18620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 669 ms | 18620 KB | Output is correct |
2 | Correct | 719 ms | 18620 KB | Output is correct |
3 | Correct | 479 ms | 18620 KB | Output is correct |