이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<long long>;
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) (x).begin() , (x).end()
const ll MOD = 998244353;
const long double EPS = 0.000000001;
const double PI = 3.14159265358979323846;
int32_t main()
{
ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
ll n, m, q; cin>>n>>m; ll arr[n+2]; arr[0]=INT_MAX, arr[n+1]=INT_MAX;
for(int l=1;l<=n;l++) cin>>arr[l];
cin>>q; vector<bool> edge(n+2, false); edge[m]=true;
ll l=m-1, r=m+1, next=m; ll ans[n+2]{0}, res=0;
while(l>=1||r<=n) {
if(arr[l]<arr[r]) next=l--;
else next=r++;
ans[next]=++res;
}
while(q--) {
char ch; cin>>ch;
if(ch=='F') {
ll a; cin>>a;
cout<<ans[a]<<'\n';
}
else if(ch=='E') {
ll a, b; cin>>a>>b;
for(int l=1;l<=n;l++) {
if(l==a) continue;
if(n-arr[l]+1>=b&&n-arr[l]+1<n-arr[a]+1) arr[l]--;
}
arr[a]=n-b+1;
}
l=m-1, r=m+1, next=m; ll res=0;
while(l>=1||r<=n) {
if(arr[l]<arr[r]) next=l--;
else next=r++;
ans[next]=++res;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |