답안 #101586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
101586 2019-03-19T04:42:11 Z rainy 케이크 (CEOI14_cake) C++14
10 / 100
2000 ms 2936 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 250005
using namespace std;
int N,A,Q,d[MAXN],od[MAXN];

int main(){
    scanf("%d%d",&N,&A);
    for(int i=1;i<=N;i++)scanf("%d",&d[i]);
    scanf("%d",&Q);
    bool prevE=true;
    int I=-1,E=-1;
    for(int i=0;i<Q;i++){
        char inp;
        scanf("  %c",&inp);
        if(inp=='E'){
            prevE=true;
            scanf("%d%d",&I,&E);
        }
        else{
            int B;scanf("%d",&B);
            if(prevE){
                if(I!=-1&&E!=-1){
                    int orr=d[I];
                    d[I]=N-E+1;
                    for(int j=0;j<N;j++){
                        if(j!=I&&d[j]>orr&&d[j]<=d[I])d[j]--;
                    }
                }
                int s=A,e=A,sf=1;
                while(!(s==1&&e==N)){
                    if(s==1){
                        e++;od[e]=sf;
                    }
                    else if(e==N){
                        s--;od[s]=sf;
                    }
                    else if(d[s-1]<d[e+1]){
                        s--;od[s]=sf;
                    }
                    else{
                        e++;od[e]=sf;
                    }
                    sf++;
                }
            }
            printf("%d\n",od[B]);
            prevE=false;
        }
    }
    return 0;
}

Compilation message

cake.cpp: In function 'int main()':
cake.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&A);
     ~~~~~^~~~~~~~~~~~~~
cake.cpp:10:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=N;i++)scanf("%d",&d[i]);
                          ~~~~~^~~~~~~~~~~~
cake.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&Q);
     ~~~~~^~~~~~~~~
cake.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("  %c",&inp);
         ~~~~~^~~~~~~~~~~~~
cake.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d%d",&I,&E);
             ~~~~~^~~~~~~~~~~~~~
cake.cpp:22:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             int B;scanf("%d",&B);
                   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 166 ms 476 KB Output isn't correct
2 Incorrect 152 ms 384 KB Output isn't correct
3 Incorrect 191 ms 384 KB Output isn't correct
4 Correct 125 ms 480 KB Output is correct
5 Incorrect 156 ms 632 KB Output isn't correct
6 Incorrect 150 ms 484 KB Output isn't correct
7 Incorrect 165 ms 512 KB Output isn't correct
8 Correct 143 ms 584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 1628 KB Output is correct
2 Correct 54 ms 1524 KB Output is correct
3 Correct 64 ms 1528 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Correct 189 ms 2928 KB Output is correct
6 Correct 158 ms 2936 KB Output is correct
7 Correct 100 ms 2708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 213 ms 564 KB Output isn't correct
2 Incorrect 362 ms 504 KB Output isn't correct
3 Execution timed out 2088 ms 896 KB Time limit exceeded
4 Execution timed out 2028 ms 1144 KB Time limit exceeded
5 Incorrect 402 ms 644 KB Output isn't correct
6 Execution timed out 2013 ms 1248 KB Time limit exceeded
7 Execution timed out 2041 ms 1124 KB Time limit exceeded
8 Incorrect 518 ms 1152 KB Output isn't correct
9 Execution timed out 2023 ms 2352 KB Time limit exceeded
10 Incorrect 1402 ms 1416 KB Output isn't correct
11 Execution timed out 2017 ms 764 KB Time limit exceeded
12 Execution timed out 2094 ms 2180 KB Time limit exceeded
13 Execution timed out 2036 ms 2680 KB Time limit exceeded