# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
26601 |
2017-07-03T12:28:36 Z |
model_code |
Lollipop (POI11_liz) |
C++14 |
|
639 ms |
9904 KB |
/*************************************************************************
* *
* XVIII Olimpiada Informatyczna *
* *
* Zadanie: Lizak *
* Autor: Adam Karczmarz *
* Zlozonosc czasowa: O(n + m) *
* pamieciowa: O(n) *
* Opis: Rozwiazanie alternatywne *
* *
*************************************************************************/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
using namespace std;
const int MAX_N=1000010;
char c[MAX_N]; int gdzie[2*MAX_N], e[2];
int main(void) {
int n, m, i, j=0, k, mx=0;
assert(scanf("%d%d%s", &n, &m, c)==3);
for(i=0; i<n; ++i)
c[i]=(c[i]=='T'?2:1);
for(j=0; j<n; ++j) {
if(c[j]==1)
break;
}
memset(gdzie, -1, sizeof(int)*2*(n+1));
for(i=j; i<n; ++i) {
mx+=c[i]; gdzie[mx]=i;
e[mx&1]=max(e[mx&1], mx);
}
while(m--) {
assert(scanf("%d", &k)==1);
if(j==n) {
if((k&1) || k>(n<<1))
puts("NIE");
else
printf("%d %d\n", 1, k>>1);
}
else {
if(!(k&1) && k<=2*j)
printf("%d %d\n", 1, k>>1);
else if(k<=mx) {
if(gdzie[k]!=-1)
printf("%d %d\n", j+1, gdzie[k]+1);
else
printf("%d %d\n", j+2, gdzie[k+1]+1);
}
else {
if(k<=(j<<1)+e[k&1])
printf("%d %d\n", j-((k-e[k&1])>>1)+1, gdzie[e[k&1]]+1);
else
puts("NIE");
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9904 KB |
Output is correct |
2 |
Correct |
0 ms |
9904 KB |
Output is correct |
3 |
Correct |
0 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9904 KB |
Output is correct |
2 |
Correct |
0 ms |
9904 KB |
Output is correct |
3 |
Correct |
0 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
9904 KB |
Output is correct |
2 |
Correct |
0 ms |
9904 KB |
Output is correct |
3 |
Correct |
3 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
9904 KB |
Output is correct |
2 |
Correct |
3 ms |
9904 KB |
Output is correct |
3 |
Correct |
3 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
9904 KB |
Output is correct |
2 |
Correct |
9 ms |
9904 KB |
Output is correct |
3 |
Correct |
53 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
9904 KB |
Output is correct |
2 |
Correct |
199 ms |
9904 KB |
Output is correct |
3 |
Correct |
99 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
9904 KB |
Output is correct |
2 |
Correct |
33 ms |
9904 KB |
Output is correct |
3 |
Correct |
93 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
9904 KB |
Output is correct |
2 |
Correct |
86 ms |
9904 KB |
Output is correct |
3 |
Correct |
206 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
336 ms |
9904 KB |
Output is correct |
2 |
Correct |
306 ms |
9904 KB |
Output is correct |
3 |
Correct |
379 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
239 ms |
9904 KB |
Output is correct |
2 |
Correct |
249 ms |
9904 KB |
Output is correct |
3 |
Correct |
316 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
639 ms |
9904 KB |
Output is correct |
2 |
Correct |
386 ms |
9904 KB |
Output is correct |
3 |
Correct |
406 ms |
9904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
586 ms |
9904 KB |
Output is correct |
2 |
Correct |
566 ms |
9904 KB |
Output is correct |
3 |
Correct |
386 ms |
9904 KB |
Output is correct |