Submission #976303

# Submission time Handle Problem Language Result Execution time Memory
976303 2024-05-06T12:11:37 Z Darren0724 Cake (CEOI14_cake) C++17
0 / 100
147 ms 10708 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
//#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e9;
const int K=10;
int32_t main() {
    LCBorz;
    int n,k;cin>>n>>k;k--;
    vector<int> v(n);
    vector<int> ans(n);
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        a[v[i]-1]=i;
    }
    vector<int> t;
    int idx=1;
    auto upd=[&](int p)->void {
        //cout<<"upd "<<p<<endl;
        v[p]=idx++;
        t.push_back(p);
    };
    auto upd1=[&](int p,int x) {
        int last=t.size();
        upd(p);
        for(int j=last-x+1;j<=last-1;j--){
            upd(t[j]);
        }
    };
    for(int i=0;i<n;i++){
        upd(a[i]);
    }
    int q;cin>>q;
    for(int i=0;i<q;i++){
        char c;cin>>c;
        if(c=='F'){
            int p;cin>>p;p--;
            if(p==k){
                cout<<0<<endl;
                continue;
            }
            if(p>k){
                int mx=0;
                for(int j=k+1;j<=p;j++){
                    mx=max(mx,v[j]);
                }
                int cnt=p-k;
                for(int j=k-1;j>=0;j--){
                    if(v[j]>mx)break;
                    cnt++;
                }
                cout<<cnt<<endl;
            }
            else{
                int mx=0;
                for(int j=k-1;j>=p;j--){
                    mx=max(mx,v[j]);
                }
                int cnt=k-p;
                for(int j=k+1;j<n;j++){
                    if(v[j]>mx)break;
                    cnt++;
                }
                cout<<cnt<<endl;
            }
        }
        else{
            int p,x;cin>>p>>x;p--;
            upd1(p,x);
        }
    }
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 1112 KB Execution killed with signal 11
2 Runtime error 2 ms 1116 KB Execution killed with signal 11
3 Runtime error 2 ms 1116 KB Execution killed with signal 11
4 Correct 53 ms 2700 KB Output is correct
5 Runtime error 3 ms 1752 KB Execution killed with signal 11
6 Runtime error 3 ms 1748 KB Execution killed with signal 11
7 Runtime error 3 ms 1752 KB Execution killed with signal 11
8 Correct 60 ms 4900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 106 ms 4816 KB Execution killed with signal 11
2 Runtime error 14 ms 4820 KB Execution killed with signal 11
3 Runtime error 14 ms 4824 KB Execution killed with signal 11
4 Runtime error 1 ms 348 KB Execution killed with signal 11
5 Runtime error 70 ms 10644 KB Execution killed with signal 11
6 Runtime error 147 ms 10696 KB Execution killed with signal 11
7 Runtime error 23 ms 10708 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 11
2 Runtime error 2 ms 860 KB Execution killed with signal 11
3 Runtime error 5 ms 2780 KB Execution killed with signal 11
4 Runtime error 5 ms 2780 KB Execution killed with signal 11
5 Runtime error 1 ms 988 KB Execution killed with signal 11
6 Runtime error 7 ms 3288 KB Execution killed with signal 11
7 Runtime error 2 ms 1116 KB Execution killed with signal 11
8 Runtime error 9 ms 4824 KB Execution killed with signal 11
9 Runtime error 23 ms 10700 KB Execution killed with signal 11
10 Runtime error 1 ms 988 KB Execution killed with signal 11
11 Runtime error 2 ms 1496 KB Execution killed with signal 11
12 Runtime error 19 ms 8828 KB Execution killed with signal 11
13 Runtime error 24 ms 10608 KB Execution killed with signal 11