#include <bits/stdc++.h>
#include "game.h"
using namespace std;
#define ll long long
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;
ll x,y;
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 ;
}
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 sx,dx;
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;
}
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;
ll x,y;
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;
}
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 sx,dx;
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);
}
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 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
4 ms |
640 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Incorrect |
3 ms |
640 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |