Submission #976312

# Submission time Handle Problem Language Result Execution time Memory
976312 2024-05-06T12:15:59 Z Darren0724 Cake (CEOI14_cake) C++17
0 / 100
2000 ms 11056 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 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 8884 KB Output isn't correct
2 Correct 56 ms 5312 KB Output is correct
3 Correct 71 ms 9396 KB Output is correct
4 Correct 61 ms 2500 KB Output is correct
5 Incorrect 63 ms 9400 KB Output isn't correct
6 Incorrect 64 ms 11056 KB Output isn't correct
7 Correct 61 ms 10020 KB Output is correct
8 Correct 62 ms 6080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 2884 KB Time limit exceeded
2 Execution timed out 2043 ms 2752 KB Time limit exceeded
3 Incorrect 1663 ms 2416 KB Output isn't correct
4 Incorrect 0 ms 600 KB Output isn't correct
5 Execution timed out 2094 ms 4836 KB Time limit exceeded
6 Execution timed out 2072 ms 4840 KB Time limit exceeded
7 Execution timed out 2059 ms 5068 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 1736 KB Output isn't correct
2 Correct 58 ms 1008 KB Output is correct
3 Correct 673 ms 2296 KB Output is correct
4 Incorrect 681 ms 2468 KB Output isn't correct
5 Incorrect 80 ms 2832 KB Output isn't correct
6 Correct 1936 ms 2668 KB Output is correct
7 Correct 409 ms 2068 KB Output is correct
8 Correct 90 ms 6748 KB Output is correct
9 Execution timed out 2080 ms 5560 KB Time limit exceeded
10 Incorrect 251 ms 10164 KB Output isn't correct
11 Incorrect 1974 ms 10676 KB Output isn't correct
12 Execution timed out 2025 ms 5056 KB Time limit exceeded
13 Execution timed out 2053 ms 5584 KB Time limit exceeded