| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 97666 | Kalam | Simple game (IZhO17_game) | C++11 | 132 ms | 6968 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// KALAM
# include<bits/stdc++.h>
using namespace std;
const int N = 1000000 + 77;
int n , q;
int a[N] , Fen[N];
inline void Add(int x , int y){
for(;x < N;x += x & - x)
Fen[x] += y;
}
inline int Get(int x){
int res = 0;
for(;x;x -= x & - x)
res += Fen[x];
return res;
}
int main() {
scanf("%d %d" , & n , & q);
for(int i = 1;i <= n;++ i) {
scanf("%d" , a + i);
if(i > 1)
Add(max(a[i] , a[i - 1]) , - 1) , Add(min(a[i] , a[i - 1]) , 1);
}
while(q --){
int tp , x , y;
scanf("%d %d" , & tp , & x);
if(tp == 2){
printf("%d\n" , Get(x));
continue ;
}
scanf("%d" , & y);
if(x > 1) {
Add(max(a[x] , a[x - 1]) , 1) , Add(min(a[x] , a[x - 1]) , - 1);
Add(max(y , a[x - 1]) , - 1) , Add(min(y , a[x - 1]) , 1);
}
if(x < n) {
Add(max(a[x] , a[x + 1]) , 1) , Add(min(a[x] , a[x + 1]) , - 1);
Add(max(y , a[x + 1]) , - 1) , Add(min(y , a[x + 1]) , 1);
}
a[x] = y;
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
