#include <bits/stdc++.h>
#define N 250050
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
int n, a, v[N], ans[N], q;
inline void process()
{
int st = a, en = a, cnt = 1;
ans[a] = 0;
while(st > 1 or en < n)
{
//cout<<st<<" "<<en<<'\n';
if( (v[st - 1] > v[en + 1] and en < n) or st <= 1)
{
ans[en + 1] = cnt;
en ++;
}
else ans[st - 1] = cnt, st --;
cnt ++;
}
//for(int i = 1; i <= n; i++) cout<<ans[i]<<" \n"[i == n];
}
pii val[N];
void update(int id, int e, int tempo)
{
val[id] = {(n - e + 1), -tempo};
}
void query()
{
int st = a, en = a, cnt = 1;
ans[a] = 0;
while(st > 1 or en < n)
{
//cout<<st<<" "<<en<<"\n";
if( (val[st - 1] > val[en + 1] and en < n) or st <= 1)
{
ans[en + 1] = cnt;
en ++;
}
else ans[st - 1] = cnt, st --;
cnt ++;
}
}
int esq[N], dir[N];
int main()
{
//ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>a;
for(int i = 1; i <= n; i++) cin>>v[i], val[i] = {v[i], 0};
query();
cin>>q;
for(int i = 1; i <= q; i++)
{
char c; int a, b;
cin>>c>>a;
if(c == 'F')
{
query();
cout<<ans[a]<<"\n";
}
else
{
cin>>b;
update(a, b, i);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
338 ms |
612 KB |
Output isn't correct |
2 |
Incorrect |
360 ms |
612 KB |
Output isn't correct |
3 |
Incorrect |
358 ms |
716 KB |
Output isn't correct |
4 |
Incorrect |
376 ms |
716 KB |
Output isn't correct |
5 |
Incorrect |
414 ms |
892 KB |
Output isn't correct |
6 |
Incorrect |
422 ms |
944 KB |
Output isn't correct |
7 |
Incorrect |
391 ms |
944 KB |
Output isn't correct |
8 |
Incorrect |
399 ms |
944 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
2436 KB |
Time limit exceeded |
2 |
Execution timed out |
2056 ms |
2436 KB |
Time limit exceeded |
3 |
Execution timed out |
2071 ms |
2500 KB |
Time limit exceeded |
4 |
Incorrect |
2 ms |
2500 KB |
Output isn't correct |
5 |
Execution timed out |
2060 ms |
4824 KB |
Time limit exceeded |
6 |
Execution timed out |
2060 ms |
4824 KB |
Time limit exceeded |
7 |
Execution timed out |
2074 ms |
4824 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
256 ms |
4824 KB |
Output isn't correct |
2 |
Incorrect |
592 ms |
4824 KB |
Output isn't correct |
3 |
Execution timed out |
2059 ms |
4824 KB |
Time limit exceeded |
4 |
Execution timed out |
2067 ms |
4824 KB |
Time limit exceeded |
5 |
Incorrect |
579 ms |
4824 KB |
Output isn't correct |
6 |
Execution timed out |
2074 ms |
4824 KB |
Time limit exceeded |
7 |
Execution timed out |
2061 ms |
4824 KB |
Time limit exceeded |
8 |
Incorrect |
810 ms |
4824 KB |
Output isn't correct |
9 |
Execution timed out |
2067 ms |
4824 KB |
Time limit exceeded |
10 |
Execution timed out |
2070 ms |
4824 KB |
Time limit exceeded |
11 |
Execution timed out |
2069 ms |
4824 KB |
Time limit exceeded |
12 |
Execution timed out |
2053 ms |
4824 KB |
Time limit exceeded |
13 |
Execution timed out |
2074 ms |
4836 KB |
Time limit exceeded |