Submission #976301

# Submission time Handle Problem Language Result Execution time Memory
976301 2024-05-06T12:09:02 Z Darren0724 Cake (CEOI14_cake) C++17
0 / 100
2000 ms 13428 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-1;j>last-x;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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 11712 KB Output isn't correct
2 Incorrect 55 ms 7364 KB Output isn't correct
3 Incorrect 57 ms 12484 KB Output isn't correct
4 Correct 54 ms 5316 KB Output is correct
5 Incorrect 64 ms 11720 KB Output isn't correct
6 Incorrect 61 ms 12212 KB Output isn't correct
7 Incorrect 63 ms 13428 KB Output isn't correct
8 Correct 62 ms 9152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2066 ms 3420 KB Time limit exceeded
2 Execution timed out 2044 ms 3624 KB Time limit exceeded
3 Incorrect 1760 ms 3820 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Execution timed out 2083 ms 6364 KB Time limit exceeded
6 Execution timed out 2044 ms 6168 KB Time limit exceeded
7 Execution timed out 2043 ms 6420 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 2008 KB Output isn't correct
2 Incorrect 51 ms 1508 KB Output isn't correct
3 Incorrect 670 ms 3160 KB Output isn't correct
4 Incorrect 665 ms 3056 KB Output isn't correct
5 Incorrect 74 ms 3492 KB Output isn't correct
6 Incorrect 1744 ms 4024 KB Output isn't correct
7 Incorrect 432 ms 3868 KB Output isn't correct
8 Incorrect 100 ms 9424 KB Output isn't correct
9 Execution timed out 2077 ms 7144 KB Time limit exceeded
10 Incorrect 248 ms 11960 KB Output isn't correct
11 Incorrect 1821 ms 12788 KB Output isn't correct
12 Execution timed out 2033 ms 6068 KB Time limit exceeded
13 Execution timed out 2016 ms 6860 KB Time limit exceeded