# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100513 | Sakamotoo | Game (IOI14_game) | C++14 | 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 "game.h"
#include<bits/stdc++.h>
using namespace std;
long long r,c;
long long x[30000],y[30000],val[30000];
vector<long long> v;
int ke;
long long gcd2(long long X, long long Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
void init(int R, int C) {
r=R;
c=C;
}
void update(int P, int Q, long long K) {
bool ada=true;
for(int i=0; i<v.size(); i++){
int ind=v[i];
if(x[ind]==P&&y[ind]==Q){
val[ind]=K;
ada=false;
}
}
if(ada){
v.push_back(ke);
x[ke]=P;
y[ke]=Q;
val[ke]=K;
ke++;
}
}
long long calculate(int P, int Q, int U, int V) {
long long now=0;
for(int i=0; i<v.size(); i++){
int ind=v[i];
if(x[ind]>=P&&x[ind]<=U&&y[ind]>=Q&&y[ind]<=V) now=gcd2(now,val[ind]);
}
return now;
}