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>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "game.h"
ll gcd(ll x, ll y) {
ll tmp;
while (x != y && y != 0) {
tmp = x;
x = y;
y = tmp % y;
}
return x;
}
const int NN = 2020;
ll a[NN][NN];
vector<pair<int, int>> pa;
void init(int r, int c) {
(void)r; (void)c;
}
void update(int p, int q, ll k) {
pa.emplace_back(p, q);
a[p][q] = k;
}
ll calculate(int p, int q, int u, int v) {
ll ans = 0;
for (auto e : pa) {
if (p <= e.x && e.x <= u && q <= e.y && e.y <= v) {
ans = gcd(ans, a[e.x][e.y]);
}
}
return ans;
}
#ifdef LC
#include "grader.c"
#endif
# | 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... |