#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 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
95 ms |
3088 KB |
Output isn't correct |
2 |
Correct |
150 ms |
3188 KB |
Output is correct |
3 |
Incorrect |
114 ms |
3188 KB |
Output isn't correct |
4 |
Correct |
116 ms |
3316 KB |
Output is correct |
5 |
Incorrect |
208 ms |
3636 KB |
Output isn't correct |
6 |
Incorrect |
116 ms |
3912 KB |
Output isn't correct |
7 |
Incorrect |
140 ms |
3992 KB |
Output isn't correct |
8 |
Correct |
164 ms |
4120 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2061 ms |
5228 KB |
Time limit exceeded |
2 |
Execution timed out |
2071 ms |
5272 KB |
Time limit exceeded |
3 |
Execution timed out |
2059 ms |
5464 KB |
Time limit exceeded |
4 |
Incorrect |
3 ms |
5464 KB |
Output isn't correct |
5 |
Execution timed out |
2070 ms |
7608 KB |
Time limit exceeded |
6 |
Execution timed out |
2072 ms |
7608 KB |
Time limit exceeded |
7 |
Execution timed out |
2064 ms |
7608 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
190 ms |
7608 KB |
Output isn't correct |
2 |
Incorrect |
632 ms |
7608 KB |
Output isn't correct |
3 |
Execution timed out |
2074 ms |
7608 KB |
Time limit exceeded |
4 |
Execution timed out |
2056 ms |
7608 KB |
Time limit exceeded |
5 |
Incorrect |
479 ms |
7608 KB |
Output isn't correct |
6 |
Execution timed out |
2068 ms |
7608 KB |
Time limit exceeded |
7 |
Execution timed out |
2043 ms |
7608 KB |
Time limit exceeded |
8 |
Incorrect |
660 ms |
7608 KB |
Output isn't correct |
9 |
Execution timed out |
2057 ms |
7940 KB |
Time limit exceeded |
10 |
Incorrect |
1260 ms |
7940 KB |
Output isn't correct |
11 |
Execution timed out |
2064 ms |
7940 KB |
Time limit exceeded |
12 |
Execution timed out |
2054 ms |
7940 KB |
Time limit exceeded |
13 |
Execution timed out |
2048 ms |
7956 KB |
Time limit exceeded |