# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
60745 |
2018-07-24T15:52:11 Z |
aome |
게임 (IOI13_game) |
C++14 |
|
3350 ms |
257024 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define mid ((l + r) >> 1)
struct NodeY {
long long gcd;
NodeY *l, *r;
NodeY() : l(NULL), r(NULL), gcd(0) {}
};
struct NodeX {
NodeX *l, *r;
NodeY *v;
NodeX() : l(NULL), r(NULL), v(NULL) {}
};
int R, C;
int P, Q, U, V;
long long K;
long long res;
NodeX *root;
void init(int _R, int _C) {
R = _R, C = _C, root = new NodeX();
}
void getY(NodeY *i, int l, int r) {
if (!i) return;
if (l > V || U > r) return;
if (U <= l && r <= V) {
res = __gcd(res, i -> gcd); return;
}
getY(i -> l, l, mid);
getY(i -> r, mid + 1, r);
}
void getX(NodeX *i, int l, int r) {
if (!i) return;
if (l > Q || P > r) return;
if (P <= l && r <= Q) {
getY(i -> v, 0, C - 1); return;
}
getX(i -> l, l, mid);
getX(i -> r, mid + 1, r);
}
void updateY(NodeY *i, int l, int r) {
if (l == r) {
i -> gcd = K; return;
}
if (mid >= Q) {
if (!(i -> l)) i -> l = new NodeY();
updateY(i -> l, l, mid);
}
else {
if (!(i -> r)) i -> r = new NodeY();
updateY(i -> r, mid + 1, r);
}
long long vl = (!(i -> l) ? 0 : i -> l -> gcd);
long long vr = (!(i -> r) ? 0 : i -> r -> gcd);
i -> gcd = __gcd(vl, vr);
}
void updateX(NodeX *i, int l, int r) {
if (l == r) {
if (!(i -> v)) i -> v = new NodeY();
updateY(i -> v, 0, C - 1);
return;
}
if (mid >= P) {
if (!(i -> l)) i -> l = new NodeX();
updateX(i -> l, l, mid);
res = 0;
if (i -> r) {
getY(i -> r -> v, 0, C - 1);
}
K = __gcd(K, res);
}
else {
if (!(i -> r)) i -> r = new NodeX();
updateX(i -> r, mid + 1, r);
res = 0;
if (i -> l) {
getY(i -> l -> v, 0, C - 1);
}
K = __gcd(K, res);
}
if (!(i -> v)) i -> v = new NodeY();
updateY(i -> v, 0, C - 1);
}
void update(int _P, int _Q, long long _K) {
P = _P, Q = U = V = _Q, K = _K;
updateX(root, 0, R - 1);
}
long long calculate(int _P, int _U, int _Q, int _V) {
res = 0;
P = _P, Q = _Q, U = _U, V = _V;
getX(root, 0, R - 1);
return res;
}
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;
^~~
game.cpp: In constructor 'NodeY::NodeY()':
game.cpp:10:16: warning: 'NodeY::r' will be initialized after [-Wreorder]
NodeY *l, *r;
^
game.cpp:9:15: warning: 'long long int NodeY::gcd' [-Wreorder]
long long gcd;
^~~
game.cpp:12:5: warning: when initialized here [-Wreorder]
NodeY() : l(NULL), r(NULL), gcd(0) {}
^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
488 KB |
Output is correct |
3 |
Correct |
4 ms |
692 KB |
Output is correct |
4 |
Correct |
4 ms |
692 KB |
Output is correct |
5 |
Correct |
3 ms |
692 KB |
Output is correct |
6 |
Correct |
4 ms |
772 KB |
Output is correct |
7 |
Correct |
4 ms |
772 KB |
Output is correct |
8 |
Correct |
3 ms |
772 KB |
Output is correct |
9 |
Correct |
4 ms |
772 KB |
Output is correct |
10 |
Correct |
3 ms |
772 KB |
Output is correct |
11 |
Correct |
3 ms |
820 KB |
Output is correct |
12 |
Correct |
2 ms |
820 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
820 KB |
Output is correct |
2 |
Correct |
3 ms |
820 KB |
Output is correct |
3 |
Correct |
3 ms |
820 KB |
Output is correct |
4 |
Correct |
981 ms |
17572 KB |
Output is correct |
5 |
Correct |
660 ms |
21700 KB |
Output is correct |
6 |
Correct |
971 ms |
23372 KB |
Output is correct |
7 |
Correct |
1064 ms |
27780 KB |
Output is correct |
8 |
Correct |
674 ms |
29064 KB |
Output is correct |
9 |
Correct |
999 ms |
36888 KB |
Output is correct |
10 |
Correct |
891 ms |
40960 KB |
Output is correct |
11 |
Correct |
3 ms |
40960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
40960 KB |
Output is correct |
2 |
Correct |
4 ms |
40960 KB |
Output is correct |
3 |
Correct |
4 ms |
40960 KB |
Output is correct |
4 |
Correct |
2 ms |
40960 KB |
Output is correct |
5 |
Correct |
3 ms |
40960 KB |
Output is correct |
6 |
Correct |
5 ms |
40960 KB |
Output is correct |
7 |
Correct |
3 ms |
40960 KB |
Output is correct |
8 |
Correct |
2 ms |
40960 KB |
Output is correct |
9 |
Correct |
4 ms |
40960 KB |
Output is correct |
10 |
Correct |
4 ms |
40960 KB |
Output is correct |
11 |
Correct |
4 ms |
40960 KB |
Output is correct |
12 |
Correct |
2157 ms |
51684 KB |
Output is correct |
13 |
Correct |
2476 ms |
51684 KB |
Output is correct |
14 |
Correct |
401 ms |
51684 KB |
Output is correct |
15 |
Correct |
3325 ms |
57796 KB |
Output is correct |
16 |
Correct |
401 ms |
71336 KB |
Output is correct |
17 |
Correct |
1710 ms |
71336 KB |
Output is correct |
18 |
Correct |
3093 ms |
81856 KB |
Output is correct |
19 |
Correct |
2545 ms |
87296 KB |
Output is correct |
20 |
Correct |
2256 ms |
92200 KB |
Output is correct |
21 |
Correct |
3 ms |
92200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
92200 KB |
Output is correct |
2 |
Correct |
3 ms |
92200 KB |
Output is correct |
3 |
Correct |
4 ms |
92200 KB |
Output is correct |
4 |
Correct |
3 ms |
92200 KB |
Output is correct |
5 |
Correct |
3 ms |
92200 KB |
Output is correct |
6 |
Correct |
5 ms |
92200 KB |
Output is correct |
7 |
Correct |
3 ms |
92200 KB |
Output is correct |
8 |
Correct |
2 ms |
92200 KB |
Output is correct |
9 |
Correct |
4 ms |
92200 KB |
Output is correct |
10 |
Correct |
4 ms |
92200 KB |
Output is correct |
11 |
Correct |
3 ms |
92200 KB |
Output is correct |
12 |
Correct |
1020 ms |
92200 KB |
Output is correct |
13 |
Correct |
825 ms |
95216 KB |
Output is correct |
14 |
Correct |
1004 ms |
96984 KB |
Output is correct |
15 |
Correct |
1179 ms |
101172 KB |
Output is correct |
16 |
Correct |
646 ms |
102560 KB |
Output is correct |
17 |
Correct |
1145 ms |
110232 KB |
Output is correct |
18 |
Correct |
939 ms |
114512 KB |
Output is correct |
19 |
Correct |
2075 ms |
125228 KB |
Output is correct |
20 |
Correct |
2459 ms |
125228 KB |
Output is correct |
21 |
Correct |
372 ms |
125228 KB |
Output is correct |
22 |
Correct |
3318 ms |
131208 KB |
Output is correct |
23 |
Correct |
438 ms |
144800 KB |
Output is correct |
24 |
Correct |
1721 ms |
144800 KB |
Output is correct |
25 |
Correct |
3350 ms |
155472 KB |
Output is correct |
26 |
Correct |
2877 ms |
160692 KB |
Output is correct |
27 |
Correct |
2509 ms |
165684 KB |
Output is correct |
28 |
Runtime error |
1896 ms |
257024 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
29 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
257024 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |