답안 #251250

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

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;
    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);
        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%s", &num, &query, 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);
         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 640 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 36 ms 1528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1528 KB Output is correct
2 Correct 145 ms 4056 KB Output is correct
3 Correct 69 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 1536 KB Output is correct
2 Correct 29 ms 1280 KB Output is correct
3 Correct 76 ms 3192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 121 ms 3704 KB Output is correct
2 Correct 99 ms 3320 KB Output is correct
3 Correct 147 ms 5752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 232 ms 9208 KB Output is correct
2 Correct 311 ms 8568 KB Output is correct
3 Correct 304 ms 11644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 302 ms 9464 KB Output is correct
2 Correct 286 ms 9976 KB Output is correct
3 Correct 340 ms 13816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 529 ms 18808 KB Output is correct
2 Correct 379 ms 15864 KB Output is correct
3 Runtime error 21 ms 16468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 452 ms 19460 KB Bledny przedzial
2 Halted 0 ms 0 KB -