Submission #965687

#TimeUsernameProblemLanguageResultExecution timeMemory
965687AmrGame (IOI13_game)C++17
0 / 100
733 ms23936 KiB
#include "game.h" #include<bits/stdc++.h> typedef long long ll; using namespace std; ll siz = 1; const int N = 2e5+3; ll seg[12][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 = 1; while(siz<=c) siz*=2; } 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 gcd = 0; for(int i = P; i <= U; i++) { //cout << get(i,Q,V+1) << endl; gcd = gcd2(gcd,get(i,Q,V+1)); } return gcd; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...