이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 3e5 + 5;
signed main() {
ios_base::sync_with_stdio(false);
cout.tie(0); cin.tie(0);
int n, s, q;
cin >> n >> s;
vector<int> v(n+1);
for(int i=1; i<=n; i++) cin >> v[i];
cin >> q;
while(q--) {
char t;
cin >> t;
if(t == 'F') {
int p;
cin >> p;
if(p == s) {
cout << 0 << '\n';
continue;
}
int l=s, r=s, ans=0;
while(l != p && r != p) {
ans++;
if(l - 1 == 0) r++;
else if(r + 1 > n) l--;
else if(v[l-1] < v[r+1]) l--;
else r++;
}
cout << ans << '\n';
} else {
int a, b;
cin >> a >> b;
int old = v[a];
v[a] = n - b + 1;
for(int i=1; i<a; i++) if(v[i] <= v[a] && old <= v[i]) v[i]--;
for(int i=a+1; i<=n; i++) if(v[i] <= v[a] && old <= v[i]) v[i]--;
}
}
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... |