이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 1000000007
#define INF 10000000
#define ll long long
//#define cin fin
//#define cout fout
#define fi first
#define se second
using namespace std;
///ofstream fout("addictive.out");
///ifstream fin("addictive.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, a; cin >> n >> a; int arr[n], ans[n] = {};
for(int i = 0; i < n; i++) {
int x; cin >> x;
arr[i] = n-x+1;
}
int cnt = 1;
int l = a-2, r = a;
while(l >= 0 || r < n) {
if(r >= n) {
ans[l] = cnt;
cnt++;
l--;
}
else if(l < 0) {
ans[r] = cnt;
cnt++;
r++;
}
else if(arr[l] > arr[r]) {
ans[l] = cnt;
cnt++;
l--;
}
else {
ans[r] = cnt;
cnt++;
r++;
}
}
int q; cin >> q;
while(q--) {
char c; cin >> c;
if(c == 'E') {
int x, y; cin >> x >> y; x--;
for(int i = 0; i < n; i++) {
if(arr[i] < arr[x] && arr[i] >= y) {arr[i]++;}
}
arr[x] = y; cnt = 1; l = a-2; r = a;
while(l >= 0 || r < n)
{
if(r >= n)
{
ans[l] = cnt;
cnt++;
l--;
}
else if(l < 0)
{
ans[r] = cnt;
cnt++;
r++;
}
else if(arr[l] > arr[r])
{
ans[l] = cnt;
cnt++;
l--;
}
else
{
ans[r] = cnt;
cnt++;
r++;
}
}
}
else {
int x; cin >> x; cout << ans[x-1] << endl;
}
}
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... |