# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72946 | win11905 | Simple game (IZhO17_game) | C++11 | 5 ms | 3940 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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(1 + 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(1 + max(A[b], A[b-1]), 1);
A[b] = c;
update(min(A[b], A[b-1]), 1);
update(1 + max(A[b], A[b-1]), -1);
}
if(b != n) {
update(min(A[b], A[b+1]), -1);
update(1 + max(A[b], A[b+1]), 1);
A[b] = c;
update(min(A[b], A[b+1]), 1);
update(1 + max(A[b], A[b+1]), -1);
}
} else printf("%d\n", query(b));
}
}
컴파일 시 표준 에러 (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... |