답안 #29530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29530 2017-07-20T05:25:26 Z 사막여우(#1245) Lollipop (POI11_liz) C++14
100 / 100
666 ms 18620 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 1000005;

int n, m;
char str[MAXN];
int st[2*MAXN], ed[2*MAXN];

int main(){
	scanf("%d %d %s",&n,&m,str);
	int p = find(str, str + n, 'W') - str;
	if(p == n){
		while(m--){
			int q;
			scanf("%d",&q);
			if(q%2 == 0) printf("%d %d\n", 1, q/2);
			else puts("NIE");
		}
		return 0;
	}
	st[1] = p, ed[1] = p;
	int cnt = 1;
	int lastEven = -987654320, lastOdd = 1;
	for(int i=p+1; i<n; i++){
		cnt += (str[i] == 'W' ? 1 : 2);
		st[cnt] = p, ed[cnt] = i;
		if(str[i] == 'T'){
			st[cnt-1] = p+1;
			ed[cnt-1] = i;
		}
		if(cnt % 2 == 0) lastEven = cnt;
		else lastOdd = cnt;
	}
	while(m--){
		int q;
		scanf("%d",&q);
		if(q <= cnt) printf("%d %d\n", st[q] + 1, ed[q] + 1);
		else{
			if(q % 2 == 0 && (q - lastEven) / 2 <= p){
				printf("%d %d\n", p - (q - lastEven) / 2 + 1, ed[lastEven] + 1); 
			}
			else if(q % 2 == 1 && (q - lastOdd) / 2 <= p){
				printf("%d %d\n", p - (q - lastOdd) / 2 + 1, ed[lastOdd] + 1); 
			}
			else puts("NIE");
		}
	}
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:13:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %s",&n,&m,str);
                             ^
liz.cpp:18:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&q);
                  ^
liz.cpp:39:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
                 ^
# 결과 실행 시간 메모리 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 6 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 18620 KB Output is correct
2 Correct 13 ms 18620 KB Output is correct
3 Correct 46 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 18620 KB Output is correct
2 Correct 146 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 29 ms 18620 KB Output is correct
3 Correct 63 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 18620 KB Output is correct
2 Correct 159 ms 18620 KB Output is correct
3 Correct 216 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 18620 KB Output is correct
2 Correct 296 ms 18620 KB Output is correct
3 Correct 346 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 18620 KB Output is correct
2 Correct 366 ms 18620 KB Output is correct
3 Correct 429 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 666 ms 18620 KB Output is correct
2 Correct 463 ms 18620 KB Output is correct
3 Correct 516 ms 18620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 489 ms 18620 KB Output is correct
2 Correct 616 ms 18620 KB Output is correct
3 Correct 469 ms 18620 KB Output is correct