# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
32108 | 2017-09-26T04:39:13 Z | tlwpdus | Lollipop (POI11_liz) | C++11 | 599 ms | 21772 KB |
#include <bits/stdc++.h> using namespace std; int n, m, p, fk = -1; int lol[4000100]; vector<int> loc; char str[1000100]; bool good(int k) { if (fk<0) return false; if (~lol[fk]&&~lol[fk+k]) { printf("%d %d\n",lol[fk]+1,lol[fk+k]); return true; } int idx = upper_bound(loc.begin(),loc.end(),k)-loc.begin(); if (idx==loc.size()) return false; int l = loc[idx]; if (~lol[l-k]&&lol[l]) { printf("%d %d\n",lol[l-k]+1,lol[l]); return true; } return false; } int main() { int i, t = 1; scanf("%d%d",&n,&m); scanf("%s",str); memset(lol,-1,sizeof(lol)); lol[0] = 0; for (i=0;i<n;i++) { if (str[i]=='T') {p+=2; lol[p] = i+1;} else {p++; lol[p] = i+1; loc.push_back(p); if (fk<0) fk = p;} } for (i=0;i<m;i++) { int k; scanf("%d",&k); if (~lol[k]) { printf("%d %d\n",1,lol[k]); continue; } if (!good(k)) { printf("NIE\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18616 KB | Output is correct |
2 | Correct | 6 ms | 18616 KB | Output is correct |
3 | Correct | 0 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 18616 KB | Output is correct |
2 | Correct | 0 ms | 18616 KB | Output is correct |
3 | Correct | 0 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 18616 KB | Output is correct |
2 | Correct | 3 ms | 18616 KB | Output is correct |
3 | Correct | 3 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 18616 KB | Output is correct |
2 | Correct | 6 ms | 18616 KB | Output is correct |
3 | Correct | 3 ms | 18756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 18616 KB | Output is correct |
2 | Correct | 13 ms | 18756 KB | Output is correct |
3 | Correct | 33 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 18616 KB | Output is correct |
2 | Correct | 163 ms | 18888 KB | Output is correct |
3 | Correct | 79 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 18756 KB | Output is correct |
2 | Correct | 43 ms | 19468 KB | Output is correct |
3 | Correct | 93 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 18616 KB | Output is correct |
2 | Correct | 126 ms | 19084 KB | Output is correct |
3 | Correct | 186 ms | 18756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 336 ms | 18756 KB | Output is correct |
2 | Correct | 353 ms | 19084 KB | Output is correct |
3 | Correct | 306 ms | 18888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 239 ms | 19468 KB | Output is correct |
2 | Correct | 336 ms | 21772 KB | Output is correct |
3 | Correct | 343 ms | 18756 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 593 ms | 18616 KB | Output is correct |
2 | Correct | 523 ms | 21772 KB | Output is correct |
3 | Correct | 496 ms | 18616 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 599 ms | 19468 KB | Output is correct |
2 | Correct | 516 ms | 21772 KB | Output is correct |
3 | Correct | 463 ms | 18616 KB | Output is correct |