Submission #26607

# Submission time Handle Problem Language Result Execution time Memory
26607 2017-07-03T12:46:27 Z model_code Lollipop (POI11_liz) C++11
56 / 100
2000 ms 27484 KB
/*************************************************************************
 *                                                                       *
 *                    XVIII Olimpiada Informatyczna                      *
 *                                                                       *
 *   Zadanie:           Lizak                                            *
 *   Autor:             Adam Karczmarz                                   *
 *   Opis:              Rozwiazanie powolne, s6 bez wysz. bin.           *
 *                                                                       *
 *************************************************************************/

#include <cstdio>
#include <cstring>
#include <algorithm>

const int MAX_N=1000010;
int l[2*MAX_N], r[2*MAX_N], w[2*MAX_N];
char c[MAX_N], us[2*MAX_N];

int main(void) {
	int n, m, i, j, k, M=0;
	scanf("%d%d%s", &n, &m, c);
	for(i=0; i<n; ++i)
		c[i]=(c[i]=='T'?2:1);
	memset(w, -1, sizeof w);
	for(i=0; i<n; ++i) {
		M+=c[i];
		w[M]=i;
	}
	while(m--) {
		scanf("%d", &k);
		if(!us[k]) {
			us[k]=1; l[k]=-1;
			if(w[k]!=-1) {
				l[k]=1; r[k]=w[k]+1;
			}
			else if(w[k+1]!=-1) {
				for(i=w[k+1], j=k+1-c[w[k+1]]; i<n; ++i) {
					j+=c[i];
					if(w[j-k]!=-1) {
						l[k]=w[j-k]+2;
						r[k]=i+1;
						break;
					}
				}
			}	
		}
		if(l[k]==-1)
			puts("NIE");
		else
			printf("%d %d\n", l[k], r[k]);
	}
	return 0;
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:21:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s", &n, &m, c);
                            ^
liz.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 27484 KB Output is correct
2 Correct 0 ms 27484 KB Output is correct
3 Correct 0 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 27484 KB Output is correct
2 Correct 0 ms 27484 KB Output is correct
3 Correct 0 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 27484 KB Output is correct
2 Correct 0 ms 27484 KB Output is correct
3 Correct 6 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27484 KB Output is correct
2 Correct 6 ms 27484 KB Output is correct
3 Correct 3 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 27484 KB Output is correct
2 Correct 9 ms 27484 KB Output is correct
3 Correct 96 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 27484 KB Output is correct
2 Correct 149 ms 27484 KB Output is correct
3 Correct 859 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 27484 KB Output is correct
2 Correct 43 ms 27484 KB Output is correct
3 Correct 1603 ms 27484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 27484 KB Output is correct
2 Correct 126 ms 27484 KB Output is correct
3 Execution timed out 2000 ms 27484 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Correct 793 ms 27484 KB Output is correct
2 Correct 459 ms 27484 KB Output is correct
3 Execution timed out 2000 ms 27484 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Correct 419 ms 27484 KB Output is correct
2 Correct 416 ms 27484 KB Output is correct
3 Execution timed out 2000 ms 27484 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Correct 1016 ms 27484 KB Output is correct
2 Correct 439 ms 27484 KB Output is correct
3 Execution timed out 2000 ms 27484 KB Execution timed out
# Verdict Execution time Memory Grader output
1 Correct 853 ms 27484 KB Output is correct
2 Correct 793 ms 27484 KB Output is correct
3 Execution timed out 2000 ms 27484 KB Execution timed out