답안 #101485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101485 2019-03-19T03:09:26 Z rainy 케이크 (CEOI14_cake) C++14
0 / 100
2000 ms 3192 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int N,Q,A;
int d[250000],od[250000];
char aa;int bb,cc;

void proc(){
    int st=A,en=A;od[A]=0;int nesf=1;
    while(st!=0||en!=N-1){
        //printf("(%d,%d)\n",st,en);
        if(st==0){
            en++;od[en]=nesf;
        }
        else if(en==N-1){
            st--;od[st]=nesf;
        }
        else if(d[st-1]<d[en+1]){
            st--;od[st]=nesf;
        }
        else{
            en++;od[en]=nesf;
        }
        nesf++;
    }
}

int main(){
    scanf("%d%d",&N,&A);A--;
    for(int i=0;i<N;i++)scanf("%d",&d[i]);
    scanf("%d",&Q);

    proc();
    for(int it=0;it<Q;it++){
        scanf(" %c",&aa);
        if(aa=='F'){
            scanf("%d",&bb);bb--;
            printf("%d\n",od[bb]);
        }
        else{
            scanf("%d%d",&bb,&cc);
            bb--;
            int orr=d[bb];
            cc=N-orr+1;
            d[bb]=cc;
            for(int i=0;i<N;i++){
                if(d[i]>=orr&&d[i]<=cc&&i!=bb)d[i]--;
                //printf("[%d:%d]\n",i,d[i]);
            }
            proc();
        }
    }
    return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&A);A--;
     ~~~~~^~~~~~~~~~~~~~
cake.cpp:32:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<N;i++)scanf("%d",&d[i]);
                         ~~~~~^~~~~~~~~~~~
cake.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&Q);
     ~~~~~^~~~~~~~~
cake.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&aa);
         ~~~~~^~~~~~~~~~~
cake.cpp:39:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&bb);bb--;
             ~~~~~^~~~~~~~~~
cake.cpp:43:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&bb,&cc);
             ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 640 KB Time limit exceeded
2 Execution timed out 2033 ms 512 KB Time limit exceeded
3 Execution timed out 2044 ms 512 KB Time limit exceeded
4 Execution timed out 2058 ms 512 KB Time limit exceeded
5 Execution timed out 2033 ms 768 KB Time limit exceeded
6 Execution timed out 2051 ms 640 KB Time limit exceeded
7 Execution timed out 2054 ms 732 KB Time limit exceeded
8 Execution timed out 2061 ms 640 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 1984 KB Output isn't correct
2 Incorrect 96 ms 1784 KB Output isn't correct
3 Incorrect 57 ms 1824 KB Output isn't correct
4 Incorrect 2 ms 384 KB Output isn't correct
5 Incorrect 125 ms 3176 KB Output isn't correct
6 Incorrect 173 ms 3192 KB Output isn't correct
7 Incorrect 104 ms 2932 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 269 ms 756 KB Output isn't correct
2 Incorrect 472 ms 868 KB Output isn't correct
3 Execution timed out 2066 ms 1208 KB Time limit exceeded
4 Execution timed out 2037 ms 1368 KB Time limit exceeded
5 Incorrect 638 ms 1048 KB Output isn't correct
6 Execution timed out 2064 ms 1316 KB Time limit exceeded
7 Execution timed out 2029 ms 940 KB Time limit exceeded
8 Execution timed out 2058 ms 1468 KB Time limit exceeded
9 Execution timed out 2035 ms 2660 KB Time limit exceeded
10 Execution timed out 2027 ms 2132 KB Time limit exceeded
11 Execution timed out 2027 ms 1140 KB Time limit exceeded
12 Execution timed out 2060 ms 2348 KB Time limit exceeded
13 Execution timed out 2050 ms 2772 KB Time limit exceeded