| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 204758 | quocnguyen1012 | Simple game (IZhO17_game) | C++14 | 101 ms | 6904 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
class fenwick_tree
{
vector<int> cnt; int n;
public:
fenwick_tree(int _n)
{
n = _n;
cnt.assign(n + 5, 0);
}
void upd(int i, int v)
{
for (; i <= n; i += i & -i)
cnt[i] += v;
}
int sum(int i)
{
int res = 0;
for (; i; i -= i & -i)
res += cnt[i];
return res;
}
void rupd(int l, int r, int v)
{
if (l > r) swap(l, r);
upd(l, v); upd(r + 1, -v);
}
};
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
fenwick_tree ft(1e6);
int N, M; cin >> N >> M;
vector<int> a(N + 5);
for (int i = 1; i <= N; ++i){
cin >> a[i];
if (i > 1) ft.rupd(a[i - 1], a[i], 1);
}
while (M--){
int type; cin >> type;
if (type == 1){
int i, val; cin >> i >> val;
if (i > 1) ft.rupd(a[i - 1], a[i], -1);
if (i < N) ft.rupd(a[i], a[i + 1], -1);
a[i] = val;
if (i > 1) ft.rupd(a[i - 1], a[i], 1);
if (i < N) ft.rupd(a[i], a[i + 1], 1);
}
else{
int h; cin >> h;
cout << ft.sum(h) << '\n';
}
}
}
컴파일 시 표준 에러 (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... | ||||
