Submission #251239

# Submission time Handle Problem Language Result Execution time Memory
251239 2020-07-20T15:59:30 Z jimmy123 Lollipop (POI11_liz) C++14
0 / 100
426 ms 18868 KB
#include <algorithm>
#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;
    }

    while(query--){
        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");
        if(query != 1)
            printf("\n");
    }
    //delete []data;


    return 0;
}

Compilation message

liz.cpp: In function 'int main()':
liz.cpp:13: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:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", data);
     ~~~~~^~~~~~~~~~~~
liz.cpp:32: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 Incorrect 0 ms 256 KB Bledny format odpowiedzi: Nieoczekiwany znak
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 768 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1528 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1536 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 99 ms 3784 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 261 ms 8908 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 184 ms 9336 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 17912 KB Bledny przedzial
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 426 ms 18868 KB Bledny przedzial
2 Halted 0 ms 0 KB -