# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
97126 |
2019-02-14T03:03:31 Z |
E869120 |
Game (IOI13_game) |
C++14 |
|
6301 ms |
257024 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
int cnts = 0;
long long gcd2(long long X, long long Y) {
if (Y == 0) return X;
return gcd2(Y, X % Y);
}
struct Node {
public:
long long val, l, r;
};
class MeleeSegmentTree {
public:
vector<Node> dat; int size_;
void init(int I) {
size_ = 1;
while (size_ < I) size_ *= 2;
dat.push_back(Node{0LL, -1, -1});
}
void update_(int p, long long x, int cl, int cr, int u) {
if (cr - cl == 1) { dat[u].val = x; return; }
if (p < ((cl + cr) >> 1)) {
if (dat[u].l == -1) { dat[u].l = dat.size(); dat.push_back(Node{0LL, -1, -1}); }
update_(p, x, cl, (cl + cr) >> 1, dat[u].l);
}
else {
if (dat[u].r == -1) { dat[u].r = dat.size(); dat.push_back(Node{0LL, -1, -1}); }
update_(p, x, (cl + cr) >> 1, cr, dat[u].r);
}
long long e1 = 0; if (dat[u].l >= 0) e1 = dat[dat[u].l].val;
long long e2 = 0; if (dat[u].r >= 0) e2 = dat[dat[u].r].val;
dat[u].val = gcd2(e1, e2);
}
void update(int p, long long x) {
return update_(p, x, 0, size_, 0);
}
long long query_(long long l, long long r, long long a, long long b, long long u) {
if (u == -1) return 0;
if (l <= a && b <= r) {
return dat[u].val;
}
if (r <= a || b <= l) return 0;
long long P1 = query_(l, r, a, (a + b) >> 1, dat[u].l);
long long P2 = query_(l, r, (a + b) >> 1, b, dat[u].r);
return gcd2(P1, P2);
}
long long query(long long l, long long r) {
return query_(l, r, 0, size_, 0);
}
};
long long H, W;
struct Node2 {
MeleeSegmentTree val; int l, r;
};
class RangedSegmentTree {
public:
vector<Node2>dat; int size_, AX, AY, BX, BY; MeleeSegmentTree BASE;
void init(int I) {
BASE.init(W);
size_ = 1;
while (size_ < I) size_ *= 2;
dat.push_back(Node2{BASE, -1, -1});
}
void update_(int p, int q, long long x, int cl, int cr, int u) {
if (cr - cl == 1) {
//cout << "update " << u << " " << q << " " << x << endl;
dat[u].val.update(q, x); return;
}
if (p < ((cl + cr) >> 1)) {
if (dat[u].l == -1) { dat[u].l = dat.size(); dat.push_back(Node2{BASE, -1, -1}); }
update_(p, q, x, cl, (cl + cr) >> 1, dat[u].l);
}
else {
if (dat[u].r == -1) { dat[u].r = dat.size(); dat.push_back(Node2{BASE, -1, -1}); }
update_(p, q, x, (cl + cr) >> 1, cr, dat[u].r);
}
long long e1 = 0; if (dat[u].l >= 0) e1 = dat[dat[u].l].val.query(q, q+1);
long long e2 = 0; if (dat[u].r >= 0) e2 = dat[dat[u].r].val.query(q, q+1);
//cout << "update " << u << " " << q << " " << gcd2(e1, e2) << " " << e1 << " " << e2 << endl;
dat[u].val.update(q, gcd2(e1, e2));
}
void update(int p, int q, long long x) {
return update_(p, q, x, 0, size_, 0);
}
long long query_(int l, int r, int u) {
if (u == -1) return 0;
if (AX <= l && r <= BX) {
long long x = dat[u].val.query(AY, BY);
//cout << "query " << l << " " << r << " " << u << " " << x << endl;
return x;
}
if (r <= AX || BX <= l) return 0;
long long e1 = query_(l, (l + r) >> 1, dat[u].l);
long long e2 = query_((l + r) >> 1, r, dat[u].r);
return gcd2(e1, e2);
}
long long query(int ax, int ay, int bx, int by) {
bx++; by++;
AX = ax; AY = ay; BX = bx; BY = by;
return query_(0, size_, 0);
}
};
RangedSegmentTree X;
void init(int R, int C) {
H = R; W = C;
X.init(H);
}
void update(int P, int Q, long long K) {
X.update(P, Q, K);
}
long long calculate(int P, int Q, int U, int V) {
return X.query(P, Q, U, V);
}
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 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
716 ms |
14296 KB |
Output is correct |
5 |
Correct |
511 ms |
14764 KB |
Output is correct |
6 |
Correct |
786 ms |
11172 KB |
Output is correct |
7 |
Correct |
851 ms |
11740 KB |
Output is correct |
8 |
Correct |
581 ms |
8548 KB |
Output is correct |
9 |
Correct |
970 ms |
12068 KB |
Output is correct |
10 |
Correct |
808 ms |
10460 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
1275 ms |
17840 KB |
Output is correct |
13 |
Correct |
2422 ms |
8484 KB |
Output is correct |
14 |
Correct |
340 ms |
2936 KB |
Output is correct |
15 |
Correct |
2477 ms |
11060 KB |
Output is correct |
16 |
Correct |
537 ms |
21232 KB |
Output is correct |
17 |
Correct |
1534 ms |
14020 KB |
Output is correct |
18 |
Correct |
2323 ms |
21576 KB |
Output is correct |
19 |
Correct |
2110 ms |
21804 KB |
Output is correct |
20 |
Correct |
2072 ms |
21156 KB |
Output is correct |
21 |
Correct |
3 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
3 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
748 ms |
14372 KB |
Output is correct |
13 |
Correct |
535 ms |
14836 KB |
Output is correct |
14 |
Correct |
806 ms |
11148 KB |
Output is correct |
15 |
Correct |
936 ms |
11612 KB |
Output is correct |
16 |
Correct |
543 ms |
8568 KB |
Output is correct |
17 |
Correct |
884 ms |
11984 KB |
Output is correct |
18 |
Correct |
844 ms |
10680 KB |
Output is correct |
19 |
Correct |
1406 ms |
17632 KB |
Output is correct |
20 |
Correct |
2389 ms |
8648 KB |
Output is correct |
21 |
Correct |
387 ms |
2936 KB |
Output is correct |
22 |
Correct |
2617 ms |
11000 KB |
Output is correct |
23 |
Correct |
568 ms |
21468 KB |
Output is correct |
24 |
Correct |
1484 ms |
14056 KB |
Output is correct |
25 |
Correct |
2862 ms |
21600 KB |
Output is correct |
26 |
Correct |
2069 ms |
21860 KB |
Output is correct |
27 |
Correct |
2204 ms |
21276 KB |
Output is correct |
28 |
Correct |
1397 ms |
217484 KB |
Output is correct |
29 |
Correct |
3369 ms |
242944 KB |
Output is correct |
30 |
Correct |
6301 ms |
177292 KB |
Output is correct |
31 |
Correct |
5818 ms |
142636 KB |
Output is correct |
32 |
Correct |
803 ms |
3448 KB |
Output is correct |
33 |
Correct |
1227 ms |
6884 KB |
Output is correct |
34 |
Correct |
1710 ms |
237640 KB |
Output is correct |
35 |
Correct |
2590 ms |
121580 KB |
Output is correct |
36 |
Correct |
4940 ms |
237788 KB |
Output is correct |
37 |
Correct |
4599 ms |
237836 KB |
Output is correct |
38 |
Correct |
4352 ms |
237532 KB |
Output is correct |
39 |
Correct |
3313 ms |
183712 KB |
Output is correct |
40 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
512 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
755 ms |
14524 KB |
Output is correct |
13 |
Correct |
512 ms |
15024 KB |
Output is correct |
14 |
Correct |
772 ms |
11420 KB |
Output is correct |
15 |
Correct |
920 ms |
12084 KB |
Output is correct |
16 |
Correct |
584 ms |
8756 KB |
Output is correct |
17 |
Correct |
923 ms |
12380 KB |
Output is correct |
18 |
Correct |
899 ms |
10848 KB |
Output is correct |
19 |
Correct |
1394 ms |
18116 KB |
Output is correct |
20 |
Correct |
2164 ms |
8696 KB |
Output is correct |
21 |
Correct |
324 ms |
2940 KB |
Output is correct |
22 |
Correct |
2440 ms |
11016 KB |
Output is correct |
23 |
Correct |
575 ms |
21568 KB |
Output is correct |
24 |
Correct |
1569 ms |
14116 KB |
Output is correct |
25 |
Correct |
2504 ms |
21624 KB |
Output is correct |
26 |
Correct |
2196 ms |
22008 KB |
Output is correct |
27 |
Correct |
2109 ms |
21468 KB |
Output is correct |
28 |
Correct |
1519 ms |
217748 KB |
Output is correct |
29 |
Correct |
3316 ms |
242876 KB |
Output is correct |
30 |
Correct |
6196 ms |
177292 KB |
Output is correct |
31 |
Correct |
5892 ms |
142732 KB |
Output is correct |
32 |
Correct |
816 ms |
3448 KB |
Output is correct |
33 |
Correct |
1182 ms |
7068 KB |
Output is correct |
34 |
Correct |
1692 ms |
237812 KB |
Output is correct |
35 |
Correct |
2692 ms |
121508 KB |
Output is correct |
36 |
Correct |
4942 ms |
237820 KB |
Output is correct |
37 |
Correct |
3970 ms |
237880 KB |
Output is correct |
38 |
Correct |
3915 ms |
237748 KB |
Output is correct |
39 |
Runtime error |
1175 ms |
257024 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
40 |
Halted |
0 ms |
0 KB |
- |