# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72949 | win11905 | Simple game (IZhO17_game) | C++11 | 138 ms | 22652 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.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
const int MX = 1e6;
int n, m, A[N];
int t[MX];
void update(int x, int v) {
for(; x <= MX; x += x & -x) t[x-1] += v;
}
int query(int x) {
int v = 0;
for(; x; x -= x & -x) v += t[x-1];
return v;
}
int main() {
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; ++i) scanf("%d", A+i);
for(int i = 1; i < n; ++i) {
update(min(A[i], A[i+1]), 1);
update(max(A[i], A[i+1]), -1);
}
for(int i = 0, a, b, c; i < m; ++i) {
scanf("%d %d", &a, &b);
if(a == 1) {
scanf("%d", &c);
if(b != 1) {
update(min(A[b], A[b-1]), -1);
update(max(A[b], A[b-1]), 1);
update(min(c, A[b-1]), 1);
update(max(c, A[b-1]), -1);
}
if(b != n) {
update(min(A[b], A[b+1]), -1);
update(max(A[b], A[b+1]), 1);
update(min(c, A[b+1]), 1);
update(max(c, A[b+1]), -1);
}
A[b] = c;
} else printf("%d\n", query(b));
}
}
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... |