# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156915 |
2019-10-08T09:23:49 Z |
TAISA_ |
Game (IOI13_game) |
C++14 |
|
23 ms |
24972 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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;
}
int n = (1 << 11);
int dat[4010][4010];
void upd(int x, int y, ll to) {
int kx = x + n, ky = y + n;
dat[kx][ky] = to;
while (kx > 0) {
if (kx < x + n) {
dat[kx][ky] = gcd2(dat[kx << 1][ky], dat[kx << 1 | 1][ky]);
}
int k = ky;
k >>= 1;
while (k > 0) {
dat[kx][k] = gcd2(dat[kx][k << 1], dat[kx][k << 1 | 1]);
k >>= 1;
}
kx >>= 1;
}
}
ll getx(int x1, int y1, int x2, int y2, int ky, int k, int l, int r) {
if (x2 <= l || r <= x1) {
return 0;
}
if (x1 <= l && r <= x2) {
return dat[k][ky];
}
ll vl = getx(x1, y1, x2, y2, ky, k << 1, l, (l + r) / 2);
ll vr = getx(x1, y1, x2, y2, ky, k << 1 | 1, (l + r) / 2, r);
return gcd2(vl, vr);
}
ll gety(int x1, int y1, int x2, int y2, int k, int l, int r) {
if (y2 <= l || r <= y1) {
return 0;
}
if (y1 <= l && r <= y2) {
return getx(x1, y1, x2, y2, k, 1, 0, n);
}
ll vl = gety(x1, y1, x2, y2, k << 1, l, (l + r) / 2);
ll vr = gety(x1, y1, x2, y2, k << 1 | 1, (l + r) / 2, r);
return gcd2(vl, vr);
}
void init(int R, int C) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
dat[i][j] = 0;
}
}
}
void update(int P, int Q, long long K) { upd(P, Q, K); }
long long calculate(int P, int Q, int U, int V) {
return gety(P, Q, U + 1, V + 1, 1, 0, n);
}
Compilation message
grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
24952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
24952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
24972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
24952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
24952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |