제출 #976312

#제출 시각아이디문제언어결과실행 시간메모리
976312Darren0724케이크 (CEOI14_cake)C++17
0 / 100
2094 ms11056 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...