# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102578 |
2024-10-18T11:07:19 Z |
ttamx |
Game (IOI13_game) |
C++17 |
|
902 ms |
256000 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd2(ll X,ll Y){
while(Y!=0)tie(X,Y)=make_pair(Y,X%Y);
return X;
}
int n,m;
struct Node{
ll val;
int l,r;
Node():val(0LL),l(0),r(0){}
}node[16000000];
int cur_node=0;
struct SegTree{
int root;
SegTree():root(0){}
ll get(int t){
return t?node[t].val:0LL;
}
void modify(int l,int r,int &t,int x,ll v){
if(!t)t=++cur_node;
if(l==r)return void(node[t].val=v);
int m=(l+r)/2;
if(x<=m)modify(l,m,node[t].l,x,v);
else modify(m+1,r,node[t].r,x,v);
node[t].val=gcd2(get(node[t].l),get(node[t].r));
}
void modify(int x,ll v){
modify(0,m-1,root,x,v);
}
ll query(int l,int r,int &t,int x,int y){
if(y<l||r<x||!t)return 0LL;
if(x<=l&&r<=y)return node[t].val;
int m=(l+r)/2;
return gcd2(query(l,m,node[t].l,x,y),query(m+1,r,node[t].r,x,y));
}
ll query(int x,int y){
return query(0,m-1,root,x,y);
}
};
struct SegTree2D{
struct Node;
using Ptr = Node*;
struct Node{
SegTree tree;
Ptr l,r;
Node():tree(),l(),r(){}
};
Ptr root;
SegTree2D():root(){}
ll get(Ptr t,int x){
return t?t->tree.query(x,x):0LL;
}
void modify(int l,int r,Ptr &t,int x,int y,ll v){
if(!t)t=new Node();
if(l<r){
int m=(l+r)/2;
if(x<=m)modify(l,m,t->l,x,y,v);
else modify(m+1,r,t->r,x,y,v);
v=gcd2(get(t->l,y),get(t->r,y));
}
t->tree.modify(y,v);
}
void modify(int x,int y,ll v){
modify(0,n-1,root,x,y,v);
}
ll query(int l,int r,Ptr &t,int x,int y,int x2,int y2){
if(y<l||r<x||!t)return 0LL;
if(x<=l&&r<=y)return t->tree.query(x2,y2);
int m=(l+r)/2;
return gcd2(query(l,m,t->l,x,y,x2,y2),query(m+1,r,t->r,x,y,x2,y2));
}
ll query(int x,int y,int x2,int y2){
return query(0,n-1,root,x,y,x2,y2);
}
}seg;
void init(int R,int C){
n=R,m=C;
}
void update(int P,int Q,ll K){
seg.modify(P,Q,K);
}
ll calculate(int P,int Q,int U,int V){
return seg.query(P,U,Q,V);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
250676 KB |
Output is correct |
2 |
Correct |
37 ms |
250696 KB |
Output is correct |
3 |
Correct |
32 ms |
250872 KB |
Output is correct |
4 |
Correct |
35 ms |
250696 KB |
Output is correct |
5 |
Correct |
38 ms |
250696 KB |
Output is correct |
6 |
Correct |
34 ms |
250896 KB |
Output is correct |
7 |
Correct |
35 ms |
250696 KB |
Output is correct |
8 |
Correct |
31 ms |
250764 KB |
Output is correct |
9 |
Correct |
34 ms |
250704 KB |
Output is correct |
10 |
Correct |
35 ms |
250680 KB |
Output is correct |
11 |
Correct |
33 ms |
250692 KB |
Output is correct |
12 |
Correct |
33 ms |
250808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
250704 KB |
Output is correct |
2 |
Correct |
34 ms |
250696 KB |
Output is correct |
3 |
Correct |
32 ms |
250696 KB |
Output is correct |
4 |
Correct |
351 ms |
254840 KB |
Output is correct |
5 |
Correct |
238 ms |
255048 KB |
Output is correct |
6 |
Correct |
300 ms |
251976 KB |
Output is correct |
7 |
Correct |
327 ms |
251720 KB |
Output is correct |
8 |
Correct |
243 ms |
252492 KB |
Output is correct |
9 |
Correct |
317 ms |
251720 KB |
Output is correct |
10 |
Correct |
273 ms |
251216 KB |
Output is correct |
11 |
Correct |
34 ms |
250664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
250716 KB |
Output is correct |
2 |
Correct |
31 ms |
250660 KB |
Output is correct |
3 |
Correct |
32 ms |
250704 KB |
Output is correct |
4 |
Correct |
30 ms |
250704 KB |
Output is correct |
5 |
Correct |
31 ms |
250708 KB |
Output is correct |
6 |
Correct |
31 ms |
250704 KB |
Output is correct |
7 |
Correct |
32 ms |
250772 KB |
Output is correct |
8 |
Correct |
31 ms |
250696 KB |
Output is correct |
9 |
Correct |
32 ms |
250696 KB |
Output is correct |
10 |
Correct |
31 ms |
250696 KB |
Output is correct |
11 |
Correct |
32 ms |
250696 KB |
Output is correct |
12 |
Correct |
493 ms |
255048 KB |
Output is correct |
13 |
Correct |
776 ms |
251488 KB |
Output is correct |
14 |
Correct |
211 ms |
251464 KB |
Output is correct |
15 |
Correct |
877 ms |
251768 KB |
Output is correct |
16 |
Correct |
145 ms |
251720 KB |
Output is correct |
17 |
Correct |
508 ms |
252332 KB |
Output is correct |
18 |
Correct |
708 ms |
251956 KB |
Output is correct |
19 |
Correct |
638 ms |
252000 KB |
Output is correct |
20 |
Correct |
598 ms |
251580 KB |
Output is correct |
21 |
Correct |
32 ms |
250696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
250696 KB |
Output is correct |
2 |
Correct |
32 ms |
250720 KB |
Output is correct |
3 |
Correct |
33 ms |
250704 KB |
Output is correct |
4 |
Correct |
34 ms |
250704 KB |
Output is correct |
5 |
Correct |
34 ms |
250752 KB |
Output is correct |
6 |
Correct |
34 ms |
250704 KB |
Output is correct |
7 |
Correct |
32 ms |
250704 KB |
Output is correct |
8 |
Correct |
32 ms |
250716 KB |
Output is correct |
9 |
Correct |
35 ms |
250740 KB |
Output is correct |
10 |
Correct |
32 ms |
250696 KB |
Output is correct |
11 |
Correct |
32 ms |
250704 KB |
Output is correct |
12 |
Correct |
338 ms |
254740 KB |
Output is correct |
13 |
Correct |
251 ms |
255048 KB |
Output is correct |
14 |
Correct |
308 ms |
251976 KB |
Output is correct |
15 |
Correct |
333 ms |
251608 KB |
Output is correct |
16 |
Correct |
232 ms |
252308 KB |
Output is correct |
17 |
Correct |
320 ms |
251804 KB |
Output is correct |
18 |
Correct |
285 ms |
251268 KB |
Output is correct |
19 |
Correct |
503 ms |
254872 KB |
Output is correct |
20 |
Correct |
754 ms |
251676 KB |
Output is correct |
21 |
Correct |
212 ms |
251464 KB |
Output is correct |
22 |
Correct |
902 ms |
251748 KB |
Output is correct |
23 |
Correct |
151 ms |
251720 KB |
Output is correct |
24 |
Correct |
494 ms |
252304 KB |
Output is correct |
25 |
Correct |
736 ms |
251976 KB |
Output is correct |
26 |
Correct |
693 ms |
252232 KB |
Output is correct |
27 |
Correct |
593 ms |
251608 KB |
Output is correct |
28 |
Runtime error |
332 ms |
256000 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
250696 KB |
Output is correct |
2 |
Correct |
32 ms |
250696 KB |
Output is correct |
3 |
Correct |
34 ms |
250704 KB |
Output is correct |
4 |
Correct |
34 ms |
250696 KB |
Output is correct |
5 |
Correct |
39 ms |
250700 KB |
Output is correct |
6 |
Correct |
37 ms |
250696 KB |
Output is correct |
7 |
Correct |
34 ms |
250696 KB |
Output is correct |
8 |
Correct |
33 ms |
250704 KB |
Output is correct |
9 |
Correct |
34 ms |
250704 KB |
Output is correct |
10 |
Correct |
35 ms |
250724 KB |
Output is correct |
11 |
Correct |
32 ms |
250704 KB |
Output is correct |
12 |
Correct |
362 ms |
254968 KB |
Output is correct |
13 |
Correct |
244 ms |
255048 KB |
Output is correct |
14 |
Correct |
307 ms |
251976 KB |
Output is correct |
15 |
Correct |
333 ms |
251720 KB |
Output is correct |
16 |
Correct |
236 ms |
252488 KB |
Output is correct |
17 |
Correct |
415 ms |
251824 KB |
Output is correct |
18 |
Correct |
279 ms |
251180 KB |
Output is correct |
19 |
Correct |
497 ms |
255052 KB |
Output is correct |
20 |
Correct |
767 ms |
251512 KB |
Output is correct |
21 |
Correct |
212 ms |
251340 KB |
Output is correct |
22 |
Correct |
876 ms |
251720 KB |
Output is correct |
23 |
Correct |
150 ms |
251704 KB |
Output is correct |
24 |
Correct |
508 ms |
252232 KB |
Output is correct |
25 |
Correct |
728 ms |
251976 KB |
Output is correct |
26 |
Correct |
689 ms |
252152 KB |
Output is correct |
27 |
Correct |
624 ms |
251740 KB |
Output is correct |
28 |
Runtime error |
342 ms |
256000 KB |
Execution killed with signal 9 |
29 |
Halted |
0 ms |
0 KB |
- |