Submission #167581

# Submission time Handle Problem Language Result Execution time Memory
167581 2019-12-09T03:16:39 Z cgiosy Game (IOI13_game) C++17
100 / 100
7227 ms 93252 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 p, 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].p) return l<=X[i].p && X[i].p<=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 X[i].x;
		if(!i) { X[i=sz1++]={x, p, 0, 0}; return x; }
		if(s==e) return X[i].x=x;
		int m=(s+e)>>1;
		if(~X[i].p) set(X[i].p, X[i].x, s, m, X[i].l), set(X[i].p, X[i].x, m+1, e, X[i].r), X[i].p=-1;
		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 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 3 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 372 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 735 ms 8156 KB Output is correct
5 Correct 561 ms 10972 KB Output is correct
6 Correct 668 ms 8168 KB Output is correct
7 Correct 709 ms 6060 KB Output is correct
8 Correct 450 ms 6596 KB Output is correct
9 Correct 666 ms 8408 KB Output is correct
10 Correct 600 ms 8184 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 2 ms 380 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 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 1301 ms 12892 KB Output is correct
13 Correct 2616 ms 7544 KB Output is correct
14 Correct 371 ms 4984 KB Output is correct
15 Correct 3094 ms 9800 KB Output is correct
16 Correct 249 ms 10784 KB Output is correct
17 Correct 1137 ms 9540 KB Output is correct
18 Correct 1842 ms 12304 KB Output is correct
19 Correct 1531 ms 12508 KB Output is correct
20 Correct 1440 ms 11576 KB Output is correct
21 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 376 KB Output is correct
6 Correct 3 ms 368 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 752 ms 11376 KB Output is correct
13 Correct 541 ms 11144 KB Output is correct
14 Correct 644 ms 8616 KB Output is correct
15 Correct 684 ms 8472 KB Output is correct
16 Correct 452 ms 7484 KB Output is correct
17 Correct 665 ms 8576 KB Output is correct
18 Correct 593 ms 8104 KB Output is correct
19 Correct 1303 ms 12908 KB Output is correct
20 Correct 2583 ms 8028 KB Output is correct
21 Correct 368 ms 5752 KB Output is correct
22 Correct 3033 ms 9772 KB Output is correct
23 Correct 241 ms 10872 KB Output is correct
24 Correct 1047 ms 9692 KB Output is correct
25 Correct 1692 ms 12448 KB Output is correct
26 Correct 1482 ms 12436 KB Output is correct
27 Correct 1358 ms 11984 KB Output is correct
28 Correct 691 ms 26908 KB Output is correct
29 Correct 1801 ms 26144 KB Output is correct
30 Correct 5706 ms 24632 KB Output is correct
31 Correct 5325 ms 44656 KB Output is correct
32 Correct 682 ms 3272 KB Output is correct
33 Correct 975 ms 5432 KB Output is correct
34 Correct 330 ms 23592 KB Output is correct
35 Correct 1328 ms 13176 KB Output is correct
36 Correct 2553 ms 22928 KB Output is correct
37 Correct 1887 ms 23268 KB Output is correct
38 Correct 1925 ms 22600 KB Output is correct
39 Correct 1605 ms 18360 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 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 3 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 404 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 724 ms 11352 KB Output is correct
13 Correct 537 ms 11128 KB Output is correct
14 Correct 620 ms 8656 KB Output is correct
15 Correct 695 ms 8428 KB Output is correct
16 Correct 456 ms 7432 KB Output is correct
17 Correct 666 ms 8440 KB Output is correct
18 Correct 576 ms 8084 KB Output is correct
19 Correct 1288 ms 12920 KB Output is correct
20 Correct 2585 ms 8008 KB Output is correct
21 Correct 368 ms 5624 KB Output is correct
22 Correct 3032 ms 9620 KB Output is correct
23 Correct 245 ms 10748 KB Output is correct
24 Correct 1085 ms 9552 KB Output is correct
25 Correct 1737 ms 12408 KB Output is correct
26 Correct 1470 ms 12424 KB Output is correct
27 Correct 1401 ms 11768 KB Output is correct
28 Correct 688 ms 26088 KB Output is correct
29 Correct 1813 ms 25488 KB Output is correct
30 Correct 5745 ms 23552 KB Output is correct
31 Correct 5324 ms 43688 KB Output is correct
32 Correct 680 ms 2620 KB Output is correct
33 Correct 962 ms 4600 KB Output is correct
34 Correct 328 ms 22740 KB Output is correct
35 Correct 1394 ms 12716 KB Output is correct
36 Correct 2678 ms 22660 KB Output is correct
37 Correct 1980 ms 22720 KB Output is correct
38 Correct 2036 ms 22180 KB Output is correct
39 Correct 933 ms 64988 KB Output is correct
40 Correct 2782 ms 57984 KB Output is correct
41 Correct 7227 ms 54196 KB Output is correct
42 Correct 6992 ms 93252 KB Output is correct
43 Correct 602 ms 52600 KB Output is correct
44 Correct 903 ms 10884 KB Output is correct
45 Correct 1676 ms 27372 KB Output is correct
46 Correct 2964 ms 56804 KB Output is correct
47 Correct 3226 ms 56732 KB Output is correct
48 Correct 3037 ms 56296 KB Output is correct
49 Correct 2 ms 376 KB Output is correct