답안 #251243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251243 2020-07-20T16:04:34 Z jimmy123 Lollipop (POI11_liz) C++14
82 / 100
508 ms 19820 KB
#include <algorithm>
#include <stdio.h>
#include <string.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];
    memset(location, 0, sizeof(location));
    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:14: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:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", 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);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8064 KB Output is correct
2 Correct 4 ms 8064 KB Output is correct
3 Correct 4 ms 8064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8064 KB Output is correct
2 Correct 4 ms 8064 KB Output is correct
3 Correct 4 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8064 KB Output is correct
2 Correct 5 ms 8064 KB Output is correct
3 Correct 12 ms 8352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Correct 8 ms 8320 KB Output is correct
3 Correct 8 ms 8320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8320 KB Output is correct
2 Correct 13 ms 8448 KB Output is correct
3 Correct 41 ms 9208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 8960 KB Output is correct
2 Correct 139 ms 11772 KB Output is correct
3 Correct 72 ms 10232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 8824 KB Output is correct
2 Correct 34 ms 8960 KB Output is correct
3 Correct 76 ms 10488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 10812 KB Output is correct
2 Correct 104 ms 10744 KB Output is correct
3 Correct 163 ms 12920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 255 ms 14712 KB Output is correct
2 Correct 227 ms 14456 KB Output is correct
3 Correct 277 ms 16692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 13816 KB Output is correct
2 Correct 250 ms 15352 KB Output is correct
3 Correct 334 ms 17144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 449 ms 19500 KB Output is correct
2 Correct 364 ms 18340 KB Output is correct
3 Runtime error 28 ms 18168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 508 ms 19820 KB Bledny przedzial
2 Halted 0 ms 0 KB -