# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
167583 |
2019-12-09T03:23:00 Z |
cgiosy |
Game (IOI13_game) |
C++17 |
|
7657 ms |
62252 KB |
#include <bits/stdc++.h>
using namespace std;
#include "game.h"
using ll=long long;
int sz1=1, sz2=1;
struct T { ll x; int l, r; } X[60000000];
struct seg {
int N, root;
seg(const int n) : N(n-1) { root=0; }
ll get(int l, int r, int s, int e, int i) const {
if(!i || e<l || r<s) return 0;
if(l<=s && e<=r) return X[i].x;
if(X[i].r<0) return l<=~X[i].r && ~X[i].r<=r ? X[i].x : 0;
int m=(s+e)>>1;
return gcd(get(l, r, s, m, X[i].l), get(l, r, m+1, e, X[i].r));
}
ll get(int l, int r) const { return get(l, r, 0, N, root); }
ll set(int p, ll x, int s, int e, int&i) {
if(p<s || e<p) return i>0 ? X[i].x : 0;
if(i<=0) { X[i=sz1++]={x, 0, ~p}; return x; }
if(s==e) return X[i].x=x;
int m=(s+e)>>1;
if(X[i].r<0) set(~X[i].r, X[i].x, s, m, X[i].l), set(~X[i].r, X[i].x, m+1, e, X[i].r), X[i].r=max(X[i].r, 0);
return X[i].x=gcd(set(p, x, s, m, X[i].l), set(p, x, m+1, e, X[i].r));
}
void set(int p, ll x) { set(p, x, 0, N, root); }
};
struct T2 { seg* x; int l, r; } Y[4194304];
struct seg2 {
int N, M, root;
seg2(int n, int m) : N(n-1), M(m) { root=0; }
ll get(int l1, int r1, int l2, int r2, int s, int e, int i) const {
if(!i || e<l1 || r1<s) return 0;
if(l1<=s && e<=r1) return Y[i].x->get(l2, r2);
int m=(s+e)>>1;
return gcd(get(l1, r1, l2, r2, s, m, Y[i].l), get(l1, r1, l2, r2, m+1, e, Y[i].r));
}
ll get(int l1, int r1, int l2, int r2) const { return get(l1, r1, l2, r2, 0, N, root); }
ll set(int p, int q, ll x, int s, int e, int&i) {
if(p<s || e<p) return i ? Y[i].x->get(q, q) : 0;
if(!i) Y[i=sz2++].x=new seg(M);
if(s==e) {
Y[i].x->set(q, x);
return x;
}
int m=(s+e)>>1;
ll y=gcd(set(p, q, x, s, m, Y[i].l), set(p, q, x, m+1, e, Y[i].r));
Y[i].x->set(q, y);
return y;
}
void set(int p, int q, ll x) { set(p, q, x, 0, N, root); }
} *T;
void init(int R, int C) {
T=new seg2(R, C);
}
void update(int P, int Q, ll K) {
T->set(P, Q, K);
}
ll calculate(int P, int Q, int U, int V) {
return T->get(P, U, Q, 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 |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
712 ms |
6732 KB |
Output is correct |
5 |
Correct |
550 ms |
7004 KB |
Output is correct |
6 |
Correct |
610 ms |
3784 KB |
Output is correct |
7 |
Correct |
664 ms |
3832 KB |
Output is correct |
8 |
Correct |
456 ms |
5368 KB |
Output is correct |
9 |
Correct |
655 ms |
4728 KB |
Output is correct |
10 |
Correct |
568 ms |
5112 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
408 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
1306 ms |
10448 KB |
Output is correct |
13 |
Correct |
2573 ms |
5456 KB |
Output is correct |
14 |
Correct |
412 ms |
5012 KB |
Output is correct |
15 |
Correct |
3002 ms |
7724 KB |
Output is correct |
16 |
Correct |
238 ms |
8952 KB |
Output is correct |
17 |
Correct |
1026 ms |
7948 KB |
Output is correct |
18 |
Correct |
1583 ms |
10436 KB |
Output is correct |
19 |
Correct |
1418 ms |
9856 KB |
Output is correct |
20 |
Correct |
1364 ms |
9444 KB |
Output is correct |
21 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
380 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
721 ms |
10400 KB |
Output is correct |
13 |
Correct |
541 ms |
10360 KB |
Output is correct |
14 |
Correct |
628 ms |
7416 KB |
Output is correct |
15 |
Correct |
660 ms |
7584 KB |
Output is correct |
16 |
Correct |
454 ms |
7152 KB |
Output is correct |
17 |
Correct |
656 ms |
7552 KB |
Output is correct |
18 |
Correct |
589 ms |
7288 KB |
Output is correct |
19 |
Correct |
1293 ms |
11588 KB |
Output is correct |
20 |
Correct |
2559 ms |
7212 KB |
Output is correct |
21 |
Correct |
394 ms |
5624 KB |
Output is correct |
22 |
Correct |
2985 ms |
8308 KB |
Output is correct |
23 |
Correct |
239 ms |
9048 KB |
Output is correct |
24 |
Correct |
1034 ms |
8696 KB |
Output is correct |
25 |
Correct |
1676 ms |
10488 KB |
Output is correct |
26 |
Correct |
1420 ms |
10416 KB |
Output is correct |
27 |
Correct |
1330 ms |
9888 KB |
Output is correct |
28 |
Correct |
652 ms |
23400 KB |
Output is correct |
29 |
Correct |
1748 ms |
24016 KB |
Output is correct |
30 |
Correct |
6133 ms |
23488 KB |
Output is correct |
31 |
Correct |
5732 ms |
36456 KB |
Output is correct |
32 |
Correct |
715 ms |
5292 KB |
Output is correct |
33 |
Correct |
942 ms |
6700 KB |
Output is correct |
34 |
Correct |
317 ms |
24056 KB |
Output is correct |
35 |
Correct |
1271 ms |
13692 KB |
Output is correct |
36 |
Correct |
2237 ms |
20548 KB |
Output is correct |
37 |
Correct |
1813 ms |
20588 KB |
Output is correct |
38 |
Correct |
1759 ms |
20028 KB |
Output is correct |
39 |
Correct |
1537 ms |
17020 KB |
Output is correct |
40 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
252 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
716 ms |
10052 KB |
Output is correct |
13 |
Correct |
543 ms |
10232 KB |
Output is correct |
14 |
Correct |
615 ms |
7476 KB |
Output is correct |
15 |
Correct |
678 ms |
7480 KB |
Output is correct |
16 |
Correct |
451 ms |
7148 KB |
Output is correct |
17 |
Correct |
667 ms |
7576 KB |
Output is correct |
18 |
Correct |
589 ms |
7240 KB |
Output is correct |
19 |
Correct |
1288 ms |
11672 KB |
Output is correct |
20 |
Correct |
2551 ms |
6996 KB |
Output is correct |
21 |
Correct |
378 ms |
5468 KB |
Output is correct |
22 |
Correct |
2992 ms |
8528 KB |
Output is correct |
23 |
Correct |
240 ms |
5240 KB |
Output is correct |
24 |
Correct |
1047 ms |
3768 KB |
Output is correct |
25 |
Correct |
1652 ms |
5248 KB |
Output is correct |
26 |
Correct |
1481 ms |
5748 KB |
Output is correct |
27 |
Correct |
1338 ms |
7204 KB |
Output is correct |
28 |
Correct |
653 ms |
22420 KB |
Output is correct |
29 |
Correct |
1726 ms |
23596 KB |
Output is correct |
30 |
Correct |
6120 ms |
22308 KB |
Output is correct |
31 |
Correct |
5882 ms |
35076 KB |
Output is correct |
32 |
Correct |
720 ms |
4904 KB |
Output is correct |
33 |
Correct |
938 ms |
6020 KB |
Output is correct |
34 |
Correct |
310 ms |
23684 KB |
Output is correct |
35 |
Correct |
1217 ms |
12660 KB |
Output is correct |
36 |
Correct |
2075 ms |
20240 KB |
Output is correct |
37 |
Correct |
1784 ms |
20388 KB |
Output is correct |
38 |
Correct |
1763 ms |
19628 KB |
Output is correct |
39 |
Correct |
872 ms |
43916 KB |
Output is correct |
40 |
Correct |
2749 ms |
40168 KB |
Output is correct |
41 |
Correct |
7657 ms |
37020 KB |
Output is correct |
42 |
Correct |
7515 ms |
62252 KB |
Output is correct |
43 |
Correct |
595 ms |
38648 KB |
Output is correct |
44 |
Correct |
934 ms |
2956 KB |
Output is correct |
45 |
Correct |
1577 ms |
15576 KB |
Output is correct |
46 |
Correct |
2794 ms |
38204 KB |
Output is correct |
47 |
Correct |
3035 ms |
38380 KB |
Output is correct |
48 |
Correct |
2720 ms |
37648 KB |
Output is correct |
49 |
Correct |
2 ms |
376 KB |
Output is correct |