Submission #251303

# Submission time Handle Problem Language Result Execution time Memory
251303 2020-07-20T17:15:51 Z jimmy123 Lollipop (POI11_liz) C++14
100 / 100
487 ms 19832 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;
    bool isfirst = true, got = false;
    scanf("%d%d%s", &num, &query, data);

    for(int i=0;i<num;++i){
        if(data[i] == 'W'){
            pos += 1;
            last_W = pos;
            if(isfirst){
                first_W = pos;
                isfirst = false;
            }
        }
        else
            pos += 2;
        location[pos] = cnt;
        cnt += 1;
    }

    for(int 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;
            }
        }

        if(last_W != -1 && last_W > range && !got){
            if(last_W-range<=2*MAX_NUM && location[last_W-range] != 0){
                printf("%d %d", location[last_W-range]+1, location[last_W]);
                got = true;
            }
            else if(last_W-range-1<=2*MAX_NUM && location[last_W-range-1] != 0){
                printf("%d %d", location[last_W-range-1]+1, location[last_W-1]);
                got = true;
            }
        }
        
        // 找不到解
        if(!got)
            printf("NIE");
    }

    return 0;
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%s", &num, &query, data);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
liz.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &range);
         ~~~~~^~~~~~~~~~~~~~
# 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 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 644 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 36 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1528 KB Output is correct
2 Correct 131 ms 4088 KB Output is correct
3 Correct 66 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1528 KB Output is correct
2 Correct 29 ms 1280 KB Output is correct
3 Correct 72 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 133 ms 3832 KB Output is correct
2 Correct 97 ms 3448 KB Output is correct
3 Correct 153 ms 5880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 275 ms 9572 KB Output is correct
2 Correct 251 ms 8952 KB Output is correct
3 Correct 315 ms 11880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 9696 KB Output is correct
2 Correct 260 ms 10360 KB Output is correct
3 Correct 350 ms 14072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 19100 KB Output is correct
2 Correct 351 ms 16248 KB Output is correct
3 Correct 399 ms 18424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 487 ms 19704 KB Output is correct
2 Correct 455 ms 16760 KB Output is correct
3 Correct 348 ms 19832 KB Output is correct