# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251302 | 2020-07-20T17:12:38 Z | jimmy123 | Lollipop (POI11_liz) | C++14 | 515 ms | 19704 KB |
#include <stdio.h> #include <vector> #include <algorithm> using namespace std; const int MAX_NUM = 1000000; char data[MAX_NUM+1]; int location[2*MAX_NUM+1]={0}; int main(){ int num=0, query=0, cnt=1, pos=0, first_W=-1, last_W=-1, range, i, add; bool isfirst = true, got = false; scanf("%d%d%s", &num, &query, data); vector<int> Wpos; for(i=0;i<num;++i){ if(data[i] == 'W'){ pos += 1; last_W = pos; if(isfirst){ first_W = pos; Wpos.push_back(pos); isfirst = false; } if(add > 1000){ Wpos.push_back(pos); add = 0; } } else pos += 2; location[pos] = cnt; cnt += 1; add += 1; } Wpos.push_back(last_W); for(i=0;i<query;++i){ if(i != 0) printf("\n"); got = false; scanf("%d", &range); if(location[range] != 0){ printf("1 %d", location[range]); continue; } if(first_W != -1 && first_W < range){ if(first_W+range<=2*MAX_NUM && location[first_W+range] != 0){ printf("%d %d", location[first_W]+1, location[first_W+range]); got = true; } else if(first_W+range-1<=2*MAX_NUM && location[first_W+range-1] != 0){ printf("%d %d", location[first_W-1]+1, location[first_W+range-1]); got = true; } } int idx = upper_bound(Wpos.begin(), Wpos.end(), range) - Wpos.begin(); //if(last_W != -1 && last_W > range){ if(idx != Wpos.size() && !got){ if(Wpos[idx]-range<=2*MAX_NUM && location[Wpos[idx]-range] != 0){ printf("%d %d", location[Wpos[idx]-range]+1, location[Wpos[idx]]); got = true; } else if(Wpos[idx]-range-1<=2*MAX_NUM && location[Wpos[idx]-range-1] != 0){ printf("%d %d", location[Wpos[idx]-range-1]+1, location[Wpos[idx]-1]); got = true; } } // 找不到解 if(!got) printf("NIE"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 9 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 512 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 640 KB | Output is correct |
2 | Correct | 7 ms | 640 KB | Output is correct |
3 | Correct | 44 ms | 1400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 1532 KB | Output is correct |
2 | Correct | 137 ms | 4088 KB | Output is correct |
3 | Correct | 85 ms | 2552 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 1476 KB | Output is correct |
2 | Correct | 31 ms | 1272 KB | Output is correct |
3 | Correct | 73 ms | 3064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 123 ms | 3704 KB | Output is correct |
2 | Correct | 108 ms | 3252 KB | Output is correct |
3 | Correct | 155 ms | 5624 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 261 ms | 9184 KB | Output is correct |
2 | Correct | 257 ms | 8512 KB | Output is correct |
3 | Correct | 283 ms | 11384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 237 ms | 9364 KB | Output is correct |
2 | Correct | 278 ms | 10048 KB | Output is correct |
3 | Correct | 326 ms | 13660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 515 ms | 18680 KB | Output is correct |
2 | Correct | 400 ms | 15868 KB | Output is correct |
3 | Correct | 417 ms | 18096 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 478 ms | 19320 KB | Output is correct |
2 | Correct | 436 ms | 16760 KB | Output is correct |
3 | Correct | 359 ms | 19704 KB | Output is correct |