This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "game.h"
struct SEGTREE {
int n;
VL tree;
SEGTREE(int sz) {
n = 1;
while (n < sz) n *= 2;
tree = VL(2*n);
}
ll get(int N, int L, int R, int l, int r) {
if (l <= L && R <= r) return tree[N];
if (R < l || L > r) return 0;
int M = (L + R) / 2;
return __gcd(get(2*N+1, L, M, l, r), get(2*N+2, M+1, R, l, r));
}
void upd(int N, int L, int R, int i, ll s) {
if (R < i || L > i) return;
if (L == R) {
tree[N] = s;
return;
}
int M = (L + R) / 2;
upd(2*N+1, L, M, i, s);
upd(2*N+2, M+1, R, i, s);
tree[N] = __gcd(tree[2*N+1], tree[2*N+2]);
}
ll get(int l, int r) {
return get(0, 0, n-1, l, r);
}
void upd(int i, ll s) {
upd(0, 0, n-1, i, s);
}
};
vector<SEGTREE> ds;
void init(int n, int m) {
ds = vector<SEGTREE>(n, SEGTREE(m));
}
void update(int x, int y, ll s) {
ds[x].upd(y, s);
}
ll calculate(int il, int jl, int ir, int jr) {
ll ret = 0;
replr(i, il, ir) {
ret = __gcd(ret, ds[i].get(jl, jr));
}
return ret;
}
# | 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... |