#include <bits/stdc++.h>
#include "game.h"
using namespace std;
struct SegmentTree {
int n;
vector<long long> t;
SegmentTree(int _n) {
n = _n;
t.resize(4 * n);
}
void update(int id, int tl, int tr, int i, long long v) {
if (tl == tr) {
t[id] = v;
return;
}
int x = 2 * id + 1, y = x + 1, tm = (tl + tr) / 2;
if (i <= tm) {
update(x, tl, tm, i, v);
} else {
update(y, tm + 1, tr, i, v);
}
t[id] = __gcd(t[x], t[y]);
}
long long get(int id, int tl, int tr, int l, int r) {
if (r < tl || tr < l) return 0LL;
if (l <= tl && tr <= r) {
return t[id];
}
int x = 2 * id + 1, y = x + 1, tm = (tl + tr) / 2;
return __gcd(get(x, tl, tm, l, r), get(y, tm + 1, tr, l, r));
}
void update(int i, long long v) { update(0, 0, n - 1, i, v); }
long long get(int l, int r) { return get(0, 0, n - 1, l, r); }
};
int n, m;
vector<SegmentTree> a;
void init(int R, int C) {
n = R;
m = C;
for (int i = 0; i < n; i++) {
a.push_back(SegmentTree(m));
}
}
void update(int i, int j, long long k) {
a[i].update(j, k);
}
long long calculate(int p, int q, int u, int v) {
long long ans = 0;
for (int i = p; i <= u; i++) {
ans = __gcd(ans, a[i].get(q, v));
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |