#include <bits/stdc++.h>
#include "game.h"
using namespace std;
#define ll long long
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll dim=1<<30;
class segment{
public:
struct node{
ll val;
int left,right;
node(){
val=0;
left=right=-1;
}
};
vector<node> s=vector<node>(1);
node def;
void upd(int pos,int l,int r,int p,ll v){
if(l>p || r<p)return ;
if(l==r){
s[pos].val=v;
return ;
}
ll x=0,y=0;
if(p<=(l+r)/2){
if(s[pos].left==-1){
s[pos].left=s.size();
s.push_back(def);
}
if(s[pos].right!=-1)y=s[s[pos].right].val;
upd(s[pos].left,l,(l+r)/2,p,v);
x=s[s[pos].left].val;
}else{
if(s[pos].right==-1){
s[pos].right=s.size();
s.push_back(def);
}
if(s[pos].left!=-1)x=s[s[pos].left].val;
upd(s[pos].right,(l+r)/2+1,r,p,v);
y=s[s[pos].right].val;
}
s[pos].val=__gcd(x,y);
}
ll query(int pos,int l,int r,int a,int b){
if(b<l || r<a)return 0;
if(a<=l && r<=b){
return s[pos].val;
}
ll sx=0,dx=0;
if(s[pos].left!=-1)sx=query(s[pos].left,l,(l+r)/2,a,b);
if(s[pos].right!=-1)dx=query(s[pos].right,(l+r)/2+1,r,a,b);
return __gcd(sx,dx);
}
};
class segofseg{
public:
struct node{
int left,right;
segment k;
node(){
left=right=-1;
}
};
vector<node> s=vector<node>(1);
node def;
void upd(int pos,int l,int r,int p,int q,ll v){
if(l>p || r<p)return ;
if(l==r){
s[pos].k.upd(0,0,dim-1,q,v);
return;
}
ll x=0,y=0;
if(p<=(l+r)/2){
if(s[pos].left==-1){
s[pos].left=s.size();
s.push_back(def);
}
upd(s[pos].left,l,(l+r)/2,p,q,v);
}else{
if(s[pos].right==-1){
s[pos].right=s.size();
s.push_back(def);
}
upd(s[pos].right,(l+r)/2+1,r,p,q,v);
}
if(s[pos].left!=-1)x=s[s[pos].left].k.query(0,0,dim-1,q,q);
if(s[pos].right!=-1)y=s[s[pos].right].k.query(0,0,dim-1,q,q);
s[pos].k.upd(0,0,dim-1,q,__gcd(x,y));
}
ll query(int pos,int l,int r,int a,int b,int x,int y){
if(b<l || r<a)return 0;
if(a<=l && r<=b){
return s[pos].k.query(0,0,dim-1,x,y);
}
ll sx=0,dx=0;
if(s[pos].left!=-1)sx=query(s[pos].left,l,(l+r)/2,a,b,x,y);
if(s[pos].right!=-1)dx=query(s[pos].right,(l+r)/2+1,r,a,b,x,y);
return __gcd(sx,dx);
}
}tot;
void init(int R, int C) {
}
void update(int P, int Q, long long K){
tot.upd(0,0,dim-1,P,Q,K);
}
long long calculate(int P, int Q, int U, int V) {
return tot.query(0,0,dim-1,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;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
640 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
927 ms |
30232 KB |
Output is correct |
5 |
Correct |
737 ms |
30696 KB |
Output is correct |
6 |
Correct |
895 ms |
27120 KB |
Output is correct |
7 |
Correct |
940 ms |
27156 KB |
Output is correct |
8 |
Correct |
600 ms |
17716 KB |
Output is correct |
9 |
Correct |
915 ms |
26728 KB |
Output is correct |
10 |
Correct |
881 ms |
26212 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
640 KB |
Output is correct |
3 |
Correct |
3 ms |
640 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
640 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1459 ms |
16316 KB |
Output is correct |
13 |
Correct |
2068 ms |
8072 KB |
Output is correct |
14 |
Correct |
666 ms |
2648 KB |
Output is correct |
15 |
Correct |
2258 ms |
10896 KB |
Output is correct |
16 |
Correct |
761 ms |
18296 KB |
Output is correct |
17 |
Correct |
1145 ms |
13148 KB |
Output is correct |
18 |
Correct |
1795 ms |
18452 KB |
Output is correct |
19 |
Correct |
1826 ms |
18488 KB |
Output is correct |
20 |
Correct |
1649 ms |
17912 KB |
Output is correct |
21 |
Correct |
1 ms |
360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
632 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
616 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
960 ms |
29932 KB |
Output is correct |
13 |
Correct |
869 ms |
30712 KB |
Output is correct |
14 |
Correct |
1016 ms |
27320 KB |
Output is correct |
15 |
Correct |
1000 ms |
27016 KB |
Output is correct |
16 |
Correct |
672 ms |
17616 KB |
Output is correct |
17 |
Correct |
982 ms |
26820 KB |
Output is correct |
18 |
Correct |
936 ms |
26224 KB |
Output is correct |
19 |
Correct |
1553 ms |
15980 KB |
Output is correct |
20 |
Correct |
2116 ms |
7688 KB |
Output is correct |
21 |
Correct |
704 ms |
2460 KB |
Output is correct |
22 |
Correct |
2277 ms |
10692 KB |
Output is correct |
23 |
Correct |
818 ms |
18296 KB |
Output is correct |
24 |
Correct |
1275 ms |
13136 KB |
Output is correct |
25 |
Correct |
1879 ms |
18464 KB |
Output is correct |
26 |
Correct |
1741 ms |
18628 KB |
Output is correct |
27 |
Correct |
1816 ms |
17892 KB |
Output is correct |
28 |
Correct |
882 ms |
149892 KB |
Output is correct |
29 |
Correct |
1906 ms |
166564 KB |
Output is correct |
30 |
Correct |
3917 ms |
120900 KB |
Output is correct |
31 |
Correct |
3561 ms |
97392 KB |
Output is correct |
32 |
Correct |
572 ms |
2056 KB |
Output is correct |
33 |
Correct |
821 ms |
4472 KB |
Output is correct |
34 |
Correct |
983 ms |
163720 KB |
Output is correct |
35 |
Correct |
1409 ms |
83864 KB |
Output is correct |
36 |
Correct |
2267 ms |
164076 KB |
Output is correct |
37 |
Correct |
2061 ms |
164096 KB |
Output is correct |
38 |
Correct |
1992 ms |
163700 KB |
Output is correct |
39 |
Correct |
1816 ms |
126576 KB |
Output is correct |
40 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
640 KB |
Output is correct |
3 |
Correct |
3 ms |
640 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 |
640 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
508 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
939 ms |
30460 KB |
Output is correct |
13 |
Correct |
772 ms |
30828 KB |
Output is correct |
14 |
Correct |
917 ms |
27504 KB |
Output is correct |
15 |
Correct |
930 ms |
27372 KB |
Output is correct |
16 |
Correct |
611 ms |
18128 KB |
Output is correct |
17 |
Correct |
1323 ms |
27204 KB |
Output is correct |
18 |
Correct |
995 ms |
27224 KB |
Output is correct |
19 |
Correct |
1705 ms |
17144 KB |
Output is correct |
20 |
Correct |
2388 ms |
8540 KB |
Output is correct |
21 |
Correct |
668 ms |
3700 KB |
Output is correct |
22 |
Correct |
2765 ms |
11904 KB |
Output is correct |
23 |
Correct |
797 ms |
19576 KB |
Output is correct |
24 |
Correct |
1154 ms |
14328 KB |
Output is correct |
25 |
Correct |
1785 ms |
19940 KB |
Output is correct |
26 |
Correct |
1714 ms |
20080 KB |
Output is correct |
27 |
Correct |
1609 ms |
19564 KB |
Output is correct |
28 |
Correct |
1294 ms |
151008 KB |
Output is correct |
29 |
Correct |
1722 ms |
167324 KB |
Output is correct |
30 |
Correct |
3508 ms |
121492 KB |
Output is correct |
31 |
Correct |
3339 ms |
98072 KB |
Output is correct |
32 |
Correct |
540 ms |
2716 KB |
Output is correct |
33 |
Correct |
733 ms |
5168 KB |
Output is correct |
34 |
Correct |
931 ms |
164488 KB |
Output is correct |
35 |
Correct |
1250 ms |
84632 KB |
Output is correct |
36 |
Correct |
2356 ms |
164860 KB |
Output is correct |
37 |
Correct |
1963 ms |
164744 KB |
Output is correct |
38 |
Correct |
1914 ms |
164344 KB |
Output is correct |
39 |
Runtime error |
1042 ms |
256004 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
40 |
Halted |
0 ms |
0 KB |
- |