답안 #676573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676573 2022-12-31T10:22:24 Z vjudge1 케이크 (CEOI14_cake) C++17
35 / 100
2000 ms 6748 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl "\n"
const int mod = (int) 1e9+7;
const int N=2e5+5;

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n,a; cin>>n>>a;
    int d[n+5],opd[n+5];
    for (int i=1;i<=n;i++) {
      cin>>d[i];
      opd[d[i]]=i;
    }

    int when[n+5];
    when[a]=0;
    int l=a-1,r=a+1,time=1;
    while (time<n) {
      if (l>=1  && ((r>n) || (r<=n && d[l]<d[r]))) {
        when[l]=time; time++; l--;
      }
      if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
        when[r]=time; time++; r++;
      }
    }

    int q; cin>>q;
    while (q--) {
      char c; cin>>c;
      if (c=='F') {
        int x; cin>>x;
        cout<<when[x]<<endl;
      }
      else {
        int x,nw; cin>>x>>nw;
        nw=n-(nw-1);
        for (int i=d[x]+1;i<=nw;i++) {
          d[opd[i]]--; opd[d[opd[i]]]=opd[i];
        }
        d[x]=nw;
        opd[d[x]]=x;

        //for (int i=1;i<=n;i++) cout<<d[i]<<' '; cout<<endl;

        int l=a-1,r=a+1,time=1;
        while (time<n) {
          if (l>=1  && ((r>n) || (r<=n && d[l]<d[r]))) {
            when[l]=time; time++; l--;
          }
          if (r<=n && ((l<1) || (l>=1 && d[r]<d[l]))) {
            when[r]=time; time++; r++;
          }
        }
      }

    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 11 ms 340 KB Output is correct
5 Correct 248 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 632 KB Time limit exceeded
2 Execution timed out 2072 ms 576 KB Time limit exceeded
3 Execution timed out 2082 ms 648 KB Time limit exceeded
4 Execution timed out 2078 ms 656 KB Time limit exceeded
5 Execution timed out 2086 ms 852 KB Time limit exceeded
6 Execution timed out 2087 ms 972 KB Time limit exceeded
7 Execution timed out 2078 ms 884 KB Time limit exceeded
8 Execution timed out 2095 ms 928 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 3128 KB Output is correct
2 Correct 47 ms 3072 KB Output is correct
3 Correct 36 ms 2980 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 215 ms 6740 KB Output is correct
6 Correct 146 ms 6748 KB Output is correct
7 Correct 61 ms 6528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 320 ms 524 KB Output is correct
2 Correct 577 ms 520 KB Output is correct
3 Execution timed out 2092 ms 1624 KB Time limit exceeded
4 Execution timed out 2096 ms 1512 KB Time limit exceeded
5 Correct 618 ms 744 KB Output is correct
6 Execution timed out 2095 ms 1864 KB Time limit exceeded
7 Execution timed out 2095 ms 832 KB Time limit exceeded
8 Execution timed out 2099 ms 2644 KB Time limit exceeded
9 Execution timed out 2093 ms 6260 KB Time limit exceeded
10 Execution timed out 2050 ms 1512 KB Time limit exceeded
11 Execution timed out 2095 ms 928 KB Time limit exceeded
12 Execution timed out 2096 ms 4988 KB Time limit exceeded
13 Execution timed out 2099 ms 6168 KB Time limit exceeded