Submission #251247

# Submission time Handle Problem Language Result Execution time Memory
251247 2020-07-20T16:05:51 Z jimmy123 Lollipop (POI11_liz) C++14
82 / 100
462 ms 19744 KB
#include <stdio.h>

using namespace std;
char data[1000001];
int location[2000001]={0};

int main(){
    int num=0, query=0, cnt=1, pos=0, first_W=-1, last_W=-1, range;
    bool isfirst = true;
    //char* data = new char[num+1];
    scanf("%d%d", &num, &query);
    scanf("%s", 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");

        scanf("%d", &range);
        if(location[range] != 0){
            printf("1 %d", location[range]);
            continue;
        }
        if(first_W != -1 && first_W < range){
            if(location[first_W+range] != 0){
                printf("%d %d", location[first_W]+1, location[first_W+range]);
                continue;
            }
            else if(location[first_W+range-1] != 0){
                printf("%d %d", location[first_W-1]+1, location[first_W+range-1]);
                continue;
            }
        }
            
        if(last_W != -1 && last_W > range){
            if(location[last_W-range] != 0){
                printf("%d %d", location[last_W-range]+1, location[last_W]);
                continue;
            }
            else if(location[last_W-range-1] != 0){
                printf("%d %d", location[last_W-range-1]+1, location[last_W-1]);
                continue;
            }
        }
        // 找不到解
        printf("NIE");
    }
    //delete []data;


    return 0;
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &num, &query);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
liz.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", data);
     ~~~~~^~~~~~~~~~~~
liz.cpp:33: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 1 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 1 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 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 768 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 37 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1784 KB Output is correct
2 Correct 155 ms 4348 KB Output is correct
3 Correct 72 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1792 KB Output is correct
2 Correct 30 ms 1400 KB Output is correct
3 Correct 75 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 4088 KB Output is correct
2 Correct 99 ms 3704 KB Output is correct
3 Correct 150 ms 6060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 240 ms 9592 KB Output is correct
2 Correct 232 ms 9208 KB Output is correct
3 Correct 266 ms 11896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 9848 KB Output is correct
2 Correct 303 ms 10364 KB Output is correct
3 Correct 328 ms 14120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 462 ms 19192 KB Output is correct
2 Correct 388 ms 16208 KB Output is correct
3 Runtime error 20 ms 16640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 461 ms 19744 KB Bledny przedzial
2 Halted 0 ms 0 KB -