Submission #975944

# Submission time Handle Problem Language Result Execution time Memory
975944 2024-05-06T03:48:48 Z Darren0724 Cake (CEOI14_cake) C++17
0 / 100
2000 ms 11416 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=0;
    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 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 10560 KB Output isn't correct
2 Incorrect 52 ms 6592 KB Output isn't correct
3 Incorrect 55 ms 9976 KB Output isn't correct
4 Correct 52 ms 2504 KB Output is correct
5 Incorrect 61 ms 10324 KB Output isn't correct
6 Incorrect 60 ms 10944 KB Output isn't correct
7 Incorrect 59 ms 10168 KB Output isn't correct
8 Correct 74 ms 5408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2050 ms 2468 KB Time limit exceeded
2 Execution timed out 2008 ms 2840 KB Time limit exceeded
3 Incorrect 1824 ms 2556 KB Output isn't correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Execution timed out 2089 ms 4568 KB Time limit exceeded
6 Execution timed out 2024 ms 4616 KB Time limit exceeded
7 Execution timed out 2028 ms 4776 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 1740 KB Output isn't correct
2 Incorrect 52 ms 1232 KB Output isn't correct
3 Incorrect 677 ms 2184 KB Output isn't correct
4 Incorrect 661 ms 2144 KB Output isn't correct
5 Incorrect 80 ms 2632 KB Output isn't correct
6 Incorrect 1732 ms 2704 KB Output isn't correct
7 Incorrect 420 ms 1992 KB Output isn't correct
8 Incorrect 87 ms 6088 KB Output isn't correct
9 Execution timed out 2045 ms 5576 KB Time limit exceeded
10 Incorrect 252 ms 10728 KB Output isn't correct
11 Incorrect 1821 ms 11416 KB Output isn't correct
12 Execution timed out 2041 ms 5056 KB Time limit exceeded
13 Execution timed out 2048 ms 5584 KB Time limit exceeded