답안 #251249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251249 2020-07-20T16:11:20 Z jimmy123 Lollipop (POI11_liz) C++14
82 / 100
509 ms 19940 KB
#include <stdio.h>

using namespace std;

int main(){
    const int MAX_NUM = 1000000;
    char data[MAX_NUM+1];
    int location[2*MAX_NUM+1]={0};
    int num=0, query=0, cnt=1, pos=0, first_W=-1, last_W=-1, range;
    bool isfirst = true;
    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");

        scanf("%d", &range)==1;
        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:32:28: warning: value computed is not used [-Wunused-value]
         scanf("%d", &range)==1;
         ~~~~~~~~~~~~~~~~~~~^~~
liz.cpp:11: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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8192 KB Output is correct
2 Correct 4 ms 8192 KB Output is correct
3 Correct 4 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8192 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 8192 KB Output is correct
2 Correct 5 ms 8064 KB Output is correct
3 Correct 11 ms 8320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8192 KB Output is correct
2 Correct 7 ms 8192 KB Output is correct
3 Correct 8 ms 8192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 8364 KB Output is correct
2 Correct 13 ms 8320 KB Output is correct
3 Correct 40 ms 9084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 8952 KB Output is correct
2 Correct 142 ms 11496 KB Output is correct
3 Correct 74 ms 9976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 8824 KB Output is correct
2 Correct 41 ms 8832 KB Output is correct
3 Correct 77 ms 10232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 10744 KB Output is correct
2 Correct 117 ms 10616 KB Output is correct
3 Correct 157 ms 12408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 14840 KB Output is correct
2 Correct 235 ms 14328 KB Output is correct
3 Correct 274 ms 16376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 195 ms 13688 KB Output is correct
2 Correct 251 ms 15096 KB Output is correct
3 Correct 323 ms 16888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 509 ms 19508 KB Output is correct
2 Correct 358 ms 18168 KB Output is correct
3 Runtime error 19 ms 18040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 468 ms 19940 KB Bledny przedzial
2 Halted 0 ms 0 KB -