# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
256905 |
2020-08-03T11:31:59 Z |
Falcon |
게임 (IOI13_game) |
C++14 |
|
8393 ms |
57080 KB |
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include "game.h"
#ifdef DEBUG
#include "debug.hpp"
#endif
using namespace std;
#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back
#ifdef DEBUG
#define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
#define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << " " << #x << " = " << x << endl; dbg::light = 0;}
#else
#define debug(x...)
#define light_debug(x)
#endif
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> uid(1, 1 << 29);
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;
}
class treap{
struct node{
int i, p;
ll v, g;
node* l; node* r;
node(int _i, ll _v){
i = _i, v = _v, g = _v;
l = r = 0;
p = uid(rng);
}
};
using pnode = node*;
pnode root = 0;
inline ll get_gcd(pnode t){
return t ? t->g : 0;
}
inline void pull(pnode t){
if(t) t->g = gcd2(gcd2(get_gcd(t->l), get_gcd(t->r)), t->v);
}
void split(pnode t, pnode& l, pnode& r, int i){
if(!t)
l = r = 0;
else if(t->i <= i)
split(t->r, t->r, r, i), l = t;
else
split(t->l, l, t->l, i), r = t;
pull(t);
}
void merge(pnode& t, pnode l, pnode r){
if(!l || !r)
t = l ? l : r;
else if(l->p > r->p)
merge(l->r, l->r, r), t = l;
else
merge(r->l, l, r->l), t = r;
pull(t);
}
public:
void update(int i, ll v){
pnode l, m, r;
split(root, m, r, i);
split(m, l, m, i - 1);
m = new node(i, v);
merge(root, l, m);
merge(root, root, r);
}
ll query(int s, int e){
pnode l, m, r;
split(root, l, m, s - 1);
split(m, m, r, e);
ll g = get_gcd(m);
merge(root, l, m);
merge(root, root, r);
return g;
}
};
class segtree{
struct node{
treap trp;
node *l = 0; node* r = 0;
};
using pnode = node*;
int R, C;
pnode root = 0;
ll query(pnode& t, int s, int e, int p, int q, int u, int v){
if(p > e || u < s || !t)
return 0;
if(p <= s && e <= u)
return t->trp.query(q, v);
return gcd2(query(t->l, s, (s + e) >> 1, p, q, u, v), query(t->r, (s + e + 2) >> 1, e, p, q, u, v));
}
void update(pnode& t, int s, int e, int p, int q, ll v){
if(p < s || p > e)
return;
if(!t)
t = new node();
if(s == e)
t->trp.update(q, v);
else{
update(t->l, s, (s + e) >> 1, p, q, v), update(t->r, (s + e + 2) >> 1, e, p, q, v);
ll lv = query(t->l, s, (s + e) >> 1, 0, q, R - 1, q);
ll rv = query(t->r, s, (s + e) >> 1, 0, q, R - 1, q);
t->trp.update(q, gcd2(lv, rv));
}
}
public:
segtree(int _R = 0, int _C = 0){
R = _R, C = _C;
}
inline void update(int p, int q, ll v){
update(root, 0, R - 1, p, q, v);
}
inline ll query(int p, int q, int u, int v){
return query(root, 0, R - 1, p, q, u, v);
}
};
segtree seg;
void init(int R, int C) {
seg = segtree(R);
}
void update(int P, int Q, long long K) {
seg.update(P, Q, K);
}
long long calculate(int P, int Q, int U, int V) {
return seg.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;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1174 ms |
11032 KB |
Output is correct |
5 |
Correct |
555 ms |
10744 KB |
Output is correct |
6 |
Correct |
1590 ms |
8188 KB |
Output is correct |
7 |
Correct |
1785 ms |
7916 KB |
Output is correct |
8 |
Correct |
1156 ms |
7416 KB |
Output is correct |
9 |
Correct |
1691 ms |
8076 KB |
Output is correct |
10 |
Correct |
1458 ms |
7672 KB |
Output is correct |
11 |
Correct |
1 ms |
288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1899 ms |
13816 KB |
Output is correct |
13 |
Correct |
4117 ms |
10184 KB |
Output is correct |
14 |
Correct |
659 ms |
11256 KB |
Output is correct |
15 |
Correct |
4278 ms |
11320 KB |
Output is correct |
16 |
Correct |
594 ms |
11000 KB |
Output is correct |
17 |
Correct |
2454 ms |
9344 KB |
Output is correct |
18 |
Correct |
4384 ms |
12424 KB |
Output is correct |
19 |
Correct |
3603 ms |
12756 KB |
Output is correct |
20 |
Correct |
3542 ms |
12284 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1148 ms |
10884 KB |
Output is correct |
13 |
Correct |
591 ms |
10744 KB |
Output is correct |
14 |
Correct |
1566 ms |
8312 KB |
Output is correct |
15 |
Correct |
1774 ms |
8204 KB |
Output is correct |
16 |
Correct |
1167 ms |
7176 KB |
Output is correct |
17 |
Correct |
1709 ms |
8028 KB |
Output is correct |
18 |
Correct |
1483 ms |
7520 KB |
Output is correct |
19 |
Correct |
1855 ms |
13728 KB |
Output is correct |
20 |
Correct |
4003 ms |
10232 KB |
Output is correct |
21 |
Correct |
725 ms |
11260 KB |
Output is correct |
22 |
Correct |
4215 ms |
11384 KB |
Output is correct |
23 |
Correct |
586 ms |
11128 KB |
Output is correct |
24 |
Correct |
2520 ms |
9388 KB |
Output is correct |
25 |
Correct |
4545 ms |
12408 KB |
Output is correct |
26 |
Correct |
3722 ms |
12600 KB |
Output is correct |
27 |
Correct |
3405 ms |
12152 KB |
Output is correct |
28 |
Correct |
1511 ms |
31608 KB |
Output is correct |
29 |
Correct |
2850 ms |
34268 KB |
Output is correct |
30 |
Correct |
5452 ms |
25392 KB |
Output is correct |
31 |
Correct |
4938 ms |
24876 KB |
Output is correct |
32 |
Correct |
963 ms |
24696 KB |
Output is correct |
33 |
Correct |
1371 ms |
24700 KB |
Output is correct |
34 |
Correct |
816 ms |
27896 KB |
Output is correct |
35 |
Correct |
2829 ms |
21452 KB |
Output is correct |
36 |
Correct |
5483 ms |
32096 KB |
Output is correct |
37 |
Correct |
4362 ms |
32172 KB |
Output is correct |
38 |
Correct |
4173 ms |
31736 KB |
Output is correct |
39 |
Correct |
3636 ms |
27184 KB |
Output is correct |
40 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1242 ms |
11080 KB |
Output is correct |
13 |
Correct |
565 ms |
10656 KB |
Output is correct |
14 |
Correct |
1538 ms |
8120 KB |
Output is correct |
15 |
Correct |
1703 ms |
7800 KB |
Output is correct |
16 |
Correct |
1152 ms |
7224 KB |
Output is correct |
17 |
Correct |
1688 ms |
7928 KB |
Output is correct |
18 |
Correct |
1416 ms |
7544 KB |
Output is correct |
19 |
Correct |
1898 ms |
13688 KB |
Output is correct |
20 |
Correct |
4059 ms |
10216 KB |
Output is correct |
21 |
Correct |
649 ms |
11212 KB |
Output is correct |
22 |
Correct |
4304 ms |
11208 KB |
Output is correct |
23 |
Correct |
583 ms |
11000 KB |
Output is correct |
24 |
Correct |
2448 ms |
9380 KB |
Output is correct |
25 |
Correct |
4279 ms |
12688 KB |
Output is correct |
26 |
Correct |
3624 ms |
12700 KB |
Output is correct |
27 |
Correct |
3441 ms |
12200 KB |
Output is correct |
28 |
Correct |
1526 ms |
31608 KB |
Output is correct |
29 |
Correct |
2847 ms |
34284 KB |
Output is correct |
30 |
Correct |
5517 ms |
25664 KB |
Output is correct |
31 |
Correct |
4808 ms |
24976 KB |
Output is correct |
32 |
Correct |
942 ms |
24696 KB |
Output is correct |
33 |
Correct |
1324 ms |
24696 KB |
Output is correct |
34 |
Correct |
776 ms |
27896 KB |
Output is correct |
35 |
Correct |
2834 ms |
21808 KB |
Output is correct |
36 |
Correct |
5476 ms |
32004 KB |
Output is correct |
37 |
Correct |
4401 ms |
32204 KB |
Output is correct |
38 |
Correct |
4409 ms |
31636 KB |
Output is correct |
39 |
Correct |
2169 ms |
55064 KB |
Output is correct |
40 |
Correct |
4729 ms |
57080 KB |
Output is correct |
41 |
Correct |
8393 ms |
46520 KB |
Output is correct |
42 |
Correct |
7553 ms |
44956 KB |
Output is correct |
43 |
Correct |
1635 ms |
51704 KB |
Output is correct |
44 |
Correct |
1526 ms |
42360 KB |
Output is correct |
45 |
Correct |
3681 ms |
27328 KB |
Output is correct |
46 |
Correct |
7514 ms |
55928 KB |
Output is correct |
47 |
Correct |
7402 ms |
55816 KB |
Output is correct |
48 |
Correct |
6933 ms |
55400 KB |
Output is correct |
49 |
Correct |
0 ms |
256 KB |
Output is correct |