#include <bits/stdc++.h>
#include "game.h"
using namespace std;
struct Seg
{
int ul, ur, dl, dr;
long long v;
Seg() : ul(0), ur(0), dl(0), dr(0), v(0) {}
};
vector<Seg> tree;
void init(int R, int C) {tree.clear(), tree.resize(2);}
void set_tree2(int n, long long v, int p, int s=0, int e=1e9)
{
int m=(s+e)>>1;
if(s==e) {
tree[p].v=v;
return;
}
if(n<=m) {
if(tree[p].dl==0) tree[p].dl=tree.size(), tree.push_back(Seg());
set_tree2(n,v,tree[p].dl,s,m);
}
else {
if(tree[p].dr==0) tree[p].dr=tree.size(), tree.push_back(Seg());
set_tree2(n,v,tree[p].dr,m+1,e);
}
tree[p].v=gcd2(tree[tree[p].dl].v,tree[tree[p].dr].v);
}
void set_tree(int x, int y, long long v, int p=1, int s=0, int e=1e9)
{
int m=(s+e)>>1;
set_tree2(y,v,p);
if(s==e) return;
if(x<=m) {
if(tree[p].ul==0) tree[p].ul=tree.size(), tree.push_back(Seg());
set_tree(x,y,v,tree[p].ul,s,m);
}
else {
if(tree[p].ur==0) tree[p].ur=tree.size(), tree.push_back(Seg());
set_tree(x,y,v,tree[p].ur,m+1,e);
}
}
void update(int P, int Q, long long K) {set_tree(P,Q,K);}
long long get_gcd2(int n1, int n2, int p, int s=0, int e=1e9)
{
int m=(s+e)>>1;
if(p==0 || n2<s || e<n1) return 0;
if(n1<=s && e<=n2) return tree[p].v;
return gcd2(get_gcd2(n1,n2,tree[p].dl,s,m),get_gcd2(n1,n2,tree[p].dr,m+1,e));
}
long long get_gcd(int x1, int x2, int y1, int y2, int p=1, int s=0, int e=1e9)
{
int m=(s+e)>>1;
if(p==0 || x2<s || e<x1) return 0;
if(x1<=s && e<=x2) return get_gcd2(y1,y2,p);
return gcd2(get_gcd(x1,x2,y1,y2,tree[p].ul,s,m),get_gcd(x1,x2,y1,y2,tree[p].ur,m+1,e));
}
long long calculate(int P, int Q, int U, int V) {return get_gcd(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;
^~~
game.cpp: In function 'void set_tree2(int, long long int, int, int, int)':
game.cpp:32:12: error: 'gcd2' was not declared in this scope
tree[p].v=gcd2(tree[tree[p].dl].v,tree[tree[p].dr].v);
^~~~
game.cpp:32:12: note: suggested alternative: 'gcvt'
tree[p].v=gcd2(tree[tree[p].dl].v,tree[tree[p].dr].v);
^~~~
gcvt
game.cpp: In function 'long long int get_gcd2(int, int, int, int, int)':
game.cpp:57:9: error: 'gcd2' was not declared in this scope
return gcd2(get_gcd2(n1,n2,tree[p].dl,s,m),get_gcd2(n1,n2,tree[p].dr,m+1,e));
^~~~
game.cpp:57:9: note: suggested alternative: 'gcvt'
return gcd2(get_gcd2(n1,n2,tree[p].dl,s,m),get_gcd2(n1,n2,tree[p].dr,m+1,e));
^~~~
gcvt
game.cpp: In function 'long long int get_gcd(int, int, int, int, int, int, int)':
game.cpp:65:9: error: 'gcd2' was not declared in this scope
return gcd2(get_gcd(x1,x2,y1,y2,tree[p].ul,s,m),get_gcd(x1,x2,y1,y2,tree[p].ur,m+1,e));
^~~~
game.cpp:65:9: note: suggested alternative: 'gcvt'
return gcd2(get_gcd(x1,x2,y1,y2,tree[p].ul,s,m),get_gcd(x1,x2,y1,y2,tree[p].ur,m+1,e));
^~~~
gcvt