Submission #29568

# Submission time Handle Problem Language Result Execution time Memory
29568 2017-07-20T06:32:05 Z 김현수(#1240) Lollipop (POI11_liz) C++14
100 / 100
909 ms 10808 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1000005;

int n, q, sum[N], two[N];
char ipt[N];

int main()
{
	scanf("%d%d%s",&n,&q,ipt+1);
	for(int i=1;i<=n;i++) {
		sum[i] = sum[i-1] + 1 + (ipt[i] == 'T');
	}
	for(int i=n;i>=1;i--) {
		two[i] = (ipt[i] == 'T' ? two[i+1] + 1 : 0);
	}
	while(q--) {
		int T, S = 1, E = n+1;
		scanf("%d",&T);
		while(S<E) {
			int M = (S+E)/2;
			sum[M] >= T ? E = M : S = M+1;
		}
		int L = 1, R = S;
		if(S == n+1) {puts("NIE"); continue;}
		if(sum[S] != T) {
			if(two[1] <= two[S+1]) {L += two[1] + 1; R += two[1];}
			else {L += two[S+1] + 1; R += two[S+1] + 1;}
		}
		if(L <= R && 1 <= L && R <= n) printf("%d %d\n", L, R);
		else puts("NIE");
	}
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:10:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s",&n,&q,ipt+1);
                             ^
liz.cpp:19:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&T);
                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Correct 0 ms 10808 KB Output is correct
3 Correct 0 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Correct 0 ms 10808 KB Output is correct
3 Correct 0 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 10808 KB Output is correct
2 Correct 0 ms 10808 KB Output is correct
3 Correct 6 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10808 KB Output is correct
2 Correct 6 ms 10808 KB Output is correct
3 Correct 6 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 10808 KB Output is correct
2 Correct 16 ms 10808 KB Output is correct
3 Correct 63 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 10808 KB Output is correct
2 Correct 219 ms 10808 KB Output is correct
3 Correct 106 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 10808 KB Output is correct
2 Correct 43 ms 10808 KB Output is correct
3 Correct 126 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 209 ms 10808 KB Output is correct
2 Correct 139 ms 10808 KB Output is correct
3 Correct 249 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 436 ms 10808 KB Output is correct
2 Correct 456 ms 10808 KB Output is correct
3 Correct 529 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 396 ms 10808 KB Output is correct
2 Correct 493 ms 10808 KB Output is correct
3 Correct 593 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 879 ms 10808 KB Output is correct
2 Correct 643 ms 10808 KB Output is correct
3 Correct 909 ms 10808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 863 ms 10808 KB Output is correct
2 Correct 889 ms 10808 KB Output is correct
3 Correct 536 ms 10808 KB Output is correct