# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
136856 |
2019-07-26T11:13:56 Z |
Juney |
게임 (IOI13_game) |
C++14 |
|
3384 ms |
256004 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define MAX_RANGE 1000000000
#define QUERY_SIZE 22000
#define gcd(x, y) gcd2(x, y)
typedef long long ll;
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;
}
struct CNODE {
int l, r; ll val;
CNODE() : l(0), r(0), val(0) {}
};
vector<CNODE> CT;
struct CDST {
void update(int y, ll val, int l, int r, int n) {
if(l == r) {
CT[n].val = val;
return;
}
int mid = (l + r) >> 1;
if(y <= mid) {
if(CT[n].l == 0) CT[n].l = CT.size(), CT.push_back(CNODE());
update(y, val, l, mid , CT[n].l);
}
else {
if(CT[n].r == 0) CT[n].r = CT.size(), CT.push_back(CNODE());
update(y, val, mid+1, r, CT[n].r);
}
CT[n].val = gcd(CT[CT[n].l].val, CT[CT[n].r].val);
}
void update(int y, ll val, int n) {
update(y, val, 1, MAX_RANGE, n);
}
ll query(int c1, int c2, int l, int r, int n) {
if(n == 0 || r < c1 || c2 < l) return 0;
if(c1 <= l && r <= c2) return CT[n].val;
int mid = (l + r) >> 1;
return gcd(query(c1, c2, l, mid, CT[n].l), query(c1, c2, mid+1, r, CT[n].r));
}
ll query(int c1, int c2, int n) {
return query(c1, c2, 1, MAX_RANGE, n);
}
} cdst;
struct RNODE {
int l, r, croot;
int get_root() {
if(croot == 0) croot = CT.size(), CT.push_back(CNODE());
return croot;
}
RNODE() : l(0), r(0), croot(0) {}
};
int rt_sz = 1;
RNODE RT[QUERY_SIZE * 40];
struct RDST {
void mrg(int y, int n, int ln, int rn, int l=1, int r=MAX_RANGE) {
if(ln == 0 && rn == 0) return;
CT[n].val = gcd(CT[ln].val, CT[rn].val);
if(l == r) return;
int mid = (l + r) >> 1;
if(y <= mid) {
if(CT[n].l == 0) CT[n].l = CT.size(), CT.push_back(CNODE());
mrg(y, CT[n].l, CT[ln].l, CT[rn].l, l, mid);
}
else {
if(CT[n].r == 0) CT[n].r = CT.size(), CT.push_back(CNODE());
mrg(y, CT[n].r, CT[ln].r, CT[rn].r, mid+1, r);
}
}
void update(int x, int y, ll val, int l=1, int r=MAX_RANGE, int n=1) {
if(l == r) {
cdst.update(y, val, RT[n].get_root());
return;
}
int mid = (l + r) >> 1;
if(x <= mid) {
if(RT[n].l == 0) RT[n].l = ++rt_sz;
update(x, y, val, l, mid, RT[n].l);
}
else {
if(RT[n].r == 0) RT[n].r = ++rt_sz;
update(x, y, val, mid+1, r, RT[n].r);
}
mrg(y, RT[n].get_root(), RT[RT[n].l].get_root(), RT[RT[n].r].get_root());
}
ll query(int r1, int c1, int r2, int c2, int l=1, int r=MAX_RANGE, int n=1) {
if(n == 0 || r < r1 || r2 < l) return 0;
if(r1 <= l && r <= r2) return cdst.query(c1, c2, RT[n].get_root());
int mid = (l + r) >> 1;
return gcd(query(r1, c1, r2, c2, l, mid, RT[n].l), query(r1, c1, r2, c2, mid+1, r, RT[n].r));
}
} dst;
void init(int R, int C) {
CT.push_back(CNODE());
}
void update(int P, int Q, long long K) {
dst.update(P+1, Q+1, K);
}
long long calculate(int P, int Q, int U, int V) {
return dst.query(P+1, Q+1, U+1, V+1);
}
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;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
10620 KB |
Output is correct |
2 |
Correct |
14 ms |
11028 KB |
Output is correct |
3 |
Correct |
13 ms |
11128 KB |
Output is correct |
4 |
Correct |
11 ms |
10628 KB |
Output is correct |
5 |
Correct |
11 ms |
10616 KB |
Output is correct |
6 |
Correct |
13 ms |
11000 KB |
Output is correct |
7 |
Correct |
14 ms |
10744 KB |
Output is correct |
8 |
Correct |
16 ms |
10744 KB |
Output is correct |
9 |
Correct |
13 ms |
11000 KB |
Output is correct |
10 |
Correct |
12 ms |
10872 KB |
Output is correct |
11 |
Correct |
12 ms |
10872 KB |
Output is correct |
12 |
Correct |
11 ms |
10744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
10616 KB |
Output is correct |
2 |
Correct |
10 ms |
10616 KB |
Output is correct |
3 |
Correct |
11 ms |
10744 KB |
Output is correct |
4 |
Correct |
1120 ms |
46404 KB |
Output is correct |
5 |
Correct |
850 ms |
46600 KB |
Output is correct |
6 |
Correct |
1288 ms |
44416 KB |
Output is correct |
7 |
Correct |
1307 ms |
43660 KB |
Output is correct |
8 |
Correct |
860 ms |
28280 KB |
Output is correct |
9 |
Correct |
1237 ms |
43876 KB |
Output is correct |
10 |
Correct |
1103 ms |
43612 KB |
Output is correct |
11 |
Correct |
11 ms |
10616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
10616 KB |
Output is correct |
2 |
Correct |
14 ms |
11128 KB |
Output is correct |
3 |
Correct |
14 ms |
11004 KB |
Output is correct |
4 |
Correct |
11 ms |
10744 KB |
Output is correct |
5 |
Correct |
11 ms |
10616 KB |
Output is correct |
6 |
Correct |
13 ms |
11000 KB |
Output is correct |
7 |
Correct |
11 ms |
10744 KB |
Output is correct |
8 |
Correct |
11 ms |
10744 KB |
Output is correct |
9 |
Correct |
13 ms |
11000 KB |
Output is correct |
10 |
Correct |
12 ms |
10872 KB |
Output is correct |
11 |
Correct |
12 ms |
10872 KB |
Output is correct |
12 |
Correct |
1673 ms |
22056 KB |
Output is correct |
13 |
Correct |
2961 ms |
15516 KB |
Output is correct |
14 |
Correct |
799 ms |
11508 KB |
Output is correct |
15 |
Correct |
3384 ms |
19036 KB |
Output is correct |
16 |
Correct |
899 ms |
27180 KB |
Output is correct |
17 |
Correct |
2134 ms |
19764 KB |
Output is correct |
18 |
Correct |
2930 ms |
27696 KB |
Output is correct |
19 |
Correct |
2635 ms |
28016 KB |
Output is correct |
20 |
Correct |
2439 ms |
27728 KB |
Output is correct |
21 |
Correct |
11 ms |
10788 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
10744 KB |
Output is correct |
2 |
Correct |
13 ms |
11000 KB |
Output is correct |
3 |
Correct |
14 ms |
11016 KB |
Output is correct |
4 |
Correct |
11 ms |
10628 KB |
Output is correct |
5 |
Correct |
11 ms |
10616 KB |
Output is correct |
6 |
Correct |
13 ms |
11000 KB |
Output is correct |
7 |
Correct |
11 ms |
10716 KB |
Output is correct |
8 |
Correct |
11 ms |
10744 KB |
Output is correct |
9 |
Correct |
13 ms |
11100 KB |
Output is correct |
10 |
Correct |
12 ms |
10872 KB |
Output is correct |
11 |
Correct |
12 ms |
11000 KB |
Output is correct |
12 |
Correct |
1117 ms |
46484 KB |
Output is correct |
13 |
Correct |
862 ms |
46592 KB |
Output is correct |
14 |
Correct |
1169 ms |
44604 KB |
Output is correct |
15 |
Correct |
1236 ms |
43708 KB |
Output is correct |
16 |
Correct |
871 ms |
28300 KB |
Output is correct |
17 |
Correct |
1257 ms |
44048 KB |
Output is correct |
18 |
Correct |
1075 ms |
43708 KB |
Output is correct |
19 |
Correct |
1677 ms |
21936 KB |
Output is correct |
20 |
Correct |
2907 ms |
15764 KB |
Output is correct |
21 |
Correct |
797 ms |
11564 KB |
Output is correct |
22 |
Correct |
3312 ms |
19040 KB |
Output is correct |
23 |
Correct |
834 ms |
27216 KB |
Output is correct |
24 |
Correct |
1862 ms |
19608 KB |
Output is correct |
25 |
Correct |
2954 ms |
27676 KB |
Output is correct |
26 |
Correct |
2589 ms |
27952 KB |
Output is correct |
27 |
Correct |
2462 ms |
27780 KB |
Output is correct |
28 |
Correct |
1067 ms |
142552 KB |
Output is correct |
29 |
Runtime error |
2477 ms |
256004 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
30 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
10616 KB |
Output is correct |
2 |
Correct |
14 ms |
11000 KB |
Output is correct |
3 |
Correct |
13 ms |
11000 KB |
Output is correct |
4 |
Correct |
11 ms |
10616 KB |
Output is correct |
5 |
Correct |
11 ms |
10616 KB |
Output is correct |
6 |
Correct |
14 ms |
11000 KB |
Output is correct |
7 |
Correct |
13 ms |
10744 KB |
Output is correct |
8 |
Correct |
12 ms |
10744 KB |
Output is correct |
9 |
Correct |
13 ms |
11000 KB |
Output is correct |
10 |
Correct |
12 ms |
10872 KB |
Output is correct |
11 |
Correct |
12 ms |
10872 KB |
Output is correct |
12 |
Correct |
1121 ms |
46532 KB |
Output is correct |
13 |
Correct |
846 ms |
46524 KB |
Output is correct |
14 |
Correct |
1176 ms |
44412 KB |
Output is correct |
15 |
Correct |
1245 ms |
43740 KB |
Output is correct |
16 |
Correct |
856 ms |
28316 KB |
Output is correct |
17 |
Correct |
1252 ms |
43964 KB |
Output is correct |
18 |
Correct |
1087 ms |
43828 KB |
Output is correct |
19 |
Correct |
1676 ms |
21956 KB |
Output is correct |
20 |
Correct |
2898 ms |
15512 KB |
Output is correct |
21 |
Correct |
841 ms |
11584 KB |
Output is correct |
22 |
Correct |
3345 ms |
19036 KB |
Output is correct |
23 |
Correct |
882 ms |
27228 KB |
Output is correct |
24 |
Correct |
1863 ms |
19676 KB |
Output is correct |
25 |
Correct |
2912 ms |
27624 KB |
Output is correct |
26 |
Correct |
2569 ms |
28244 KB |
Output is correct |
27 |
Correct |
2351 ms |
27588 KB |
Output is correct |
28 |
Correct |
1086 ms |
142484 KB |
Output is correct |
29 |
Runtime error |
2170 ms |
256004 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
30 |
Halted |
0 ms |
0 KB |
- |