# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962882 | n3rm1n | Game (IOI13_game) | C++17 | 0 ms | 0 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>
#include "game.h"
using namespace std;
long long r, c;
void init(long long R, long long C)
{
r = R;
c = C;
}
long long t[105][400005];
long long line, ql, qr;
long long query(long long i, long long l, long long r)
{
if(ql > r || qr < l)return 0;
if(ql < l && r <= qr)return t[line][i];
long long mid = (l + r)/2;
return gcd2(query(2*i, l, mid), query(2*i+1, mid+1, r));
}
long long pnt;
long long val;
void upd(long long i, long long l, long long r)
{
if(l == r)
{
t[line][i] = val;
return;
}
long long mid = (l + r)/2;
if(pnt <= mid)upd(2*i, l, mid);
else upd(2*i+1, mid+1, r);
t[line][i] = gcd2(t[line][2*i], t[line][2*i+1]);
}
void update(long long P, long long Q, long long K)
{
P ++;
Q ++;
line = P;
pnt = Q;
val = K;
update(1, 1, c);
}
long long calculate(long long P, long long Q, long long U, long long V)
{
P ++;
Q ++;
U ++;
V ++;
long long ans = 0;
ql = Q;
qr = V;
for (line = P; line <= U; ++ line)
ans = gcd2(ans, query(1, 1, c));
return ans;
}