# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
965698 | | Amr | Game (IOI13_game) | C++17 | | 717 ms | 44944 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 "game.h"
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll siz = 1;
const int N = 5e5;
ll seg[11][N];
ll r , c;
long long gcd2(long long X, long long Y) {
long long tmp;
if(X<Y) swap(X,Y);
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
void upd(ll ver, ll in , ll val , ll x = 0, ll lx = 0, ll rx = siz)
{
// cout << lx << " " << rx << " ";
if(rx-lx==1)
{
seg[ver][x] = val;
return;
}
ll mid = (lx+rx)/2;
if(in<mid)
upd(ver,in,val,2*x+1,lx,mid);
else
upd(ver,in,val,2*x+2,mid,rx);
seg[ver][x] = gcd2(seg[ver][2*x+1],seg[ver][2*x+2]);
// cout << seg[ver][] << " ";
}
ll get(ll ver, ll l ,ll r, ll x = 0, ll lx = 0, ll rx = siz)
{
if(lx>=r||rx<=l) return 0;
if(lx>=l&&rx<=r) return seg[ver][x];
ll mid = (lx+rx)/2;
ll s1 = get(ver,l,r,2*x+1,lx,mid);
ll s2 = get(ver,l,r,2*x+2,mid,rx);
return gcd2(s1,s2);
}
void init(int R, int C) {
r = R , c = C;
siz = C;
}
void update(int P, int Q, long long K) {
upd(P,Q,K);
// cout << seg[P][0] << endl;
}
long long calculate(int P, int Q, int U, int V) {
ll gcd3 = 0;
for(int i = P; i <= U; i++)
{
//cout << get(i,Q,V+1) << endl;
gcd3= gcd2(gcd3,get(i,Q,V+1));
}
return gcd3;
}
# | 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... |