Submission #1090427

#TimeUsernameProblemLanguageResultExecution timeMemory
1090427LeonidCukGame (IOI13_game)C++17
37 / 100
645 ms40124 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int n,m; vector<long long int>st[101]; void init(int R,int C) { n=R; m=C; for(int i=0;i<n;i++) { st[i].resize(4*m+1); } } void updatest(int i,int l,int r,int a,int b,long long int k) { if(l==r) { st[a][i]=k; return; } int m=(l+r)/2; if(b<=m)updatest(i*2,l,m,a,b,k); else { updatest(i*2+1,m+1,r,a,b,k); } st[a][i]=gcd(st[a][i*2],st[a][i*2+1]); } long long int gsum(int i,int l,int r,int tl,int tr,int a) { if(tl>r||tr<l||l>r) { return 0; } if(tl<=l&&r<=tr) { return st[a][i]; } int m=(l+r)/2; return gcd(gsum(i*2,l,m,tl,tr,a),gsum(i*2+1,m+1,r,tl,tr,a)); } long long int calculate(int r1,int r2,int c1,int c2) { long long int sum=0; for(int i=r1;i<=c1;i++) { sum=gcd(sum,gsum(1,0,m-1,r2,c2,i)); } return sum; } void update(int R,int C,long long int k) { updatest(1,0,m-1,R,C,k); }
#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...