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;
int r, c;
void init(int R, int C)
{
r = R;
c = C;
}
map < pair < long long, long long >, long long > mp;
long long gcd2(long long X, long long Y) {
int ans = mp[make_pair(X, Y)];
if(ans)return ans;
long long tmp;
long long oldx = X, oldy = Y;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
mp[make_pair(oldx, oldy)] = X;
return X;
}
struct point
{
int x, y;
long long val;
point(){};
point(int _x, int _y, long long _val)
{
x = _x;
y = _y;
val = _val;
}
};
vector < point > g;
void update(int P, int Q, long long K)
{
P ++;
Q ++;
g.push_back(point(P, Q, K));
}
long long calculate(int P, int Q, int U, int V)
{
P ++;
Q ++;
U ++;
V ++;
long long ans = 0;
for (int i = 0; i < g.size(); ++ i)
{
if(g[i].x >= P && g[i].x <= U && g[i].y >= Q && g[i].y <= V)
ans = gcd2(ans, g[i].val);
}
return ans;
}
Compilation message (stderr)
game.cpp: In function 'long long int calculate(int, int, int, int)':
game.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for (int i = 0; i < g.size(); ++ i)
| ~~^~~~~~~~~~
# | 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... |