# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
65387 |
2018-08-07T13:34:23 Z |
edisonhello |
Game (IOI13_game) |
C++14 |
|
5 ms |
636 KB |
#include "game.h"
#include<bits/stdc++.h>
#define ll int_fast64_t
using namespace std;
struct nodey{
nodey *l,*r;
ll g;
nodey():l(0),r(0),g(0){}
void pull(){ g=__gcd(l?l->g:0,r?r->g:0); }
};
struct nodex{
nodex *l,*r;
nodey *root;
nodex():l(0),r(0),root(0){}
} *root;
int x,y;
void init(int R, int C){
x=R; y=C;
}
#define mid ((l+r)>>1)
void modify(nodey *&now,int l,int r,int my,ll v){
if(!now)now=new nodey();
if(l==r){ now->g=v; return; }
if(my<=mid)modify(now->l,l,mid,my,v);
else modify(now->r,mid+1,r,my,v);
now->pull();
// cout<<"nodey "<<now<<" "<<l<<" to "<<r<<" g is "<<now->g<<endl;
}
void modify(nodex *&now,int l,int r,int mx,int my,ll v){
if(!now)now=new nodex();
modify(now->root,0,y-1,my,v);
if(l==r)return;
if(mx<=mid)modify(now->l,l,mid,mx,my,v);
else modify(now->r,mid+1,r,mx,my,v);
}
void update(int p, int q, long long v){
modify(root,0,x-1,p,q,v);
}
ll query(nodey *now,int l,int r,int yl,int yr){
if(yr<l || r<yl || !now)return 0;
if(yl<=l&&r<=yr)return now->g;
return __gcd(query(now->l,l,mid,yl,yr),query(now->r,mid+1,r,yl,yr));
}
ll query(nodex *now,int l,int r,int xl,int xr,int yl,int yr){
if(xr<l || r<xl || !now)return 0;
if(xl<=l&&r<=xr)return query(now->root,0,y-1,yl,yr);
return __gcd(query(now->l,l,mid,xl,xr,yl,yr),query(now->r,mid+1,r,xl,xr,yl,yr));
}
long long calculate(int x1, int y1, int x2, int y2){
return query(root,0,x-1,x1,x2,y1,y2);
}
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;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Incorrect |
3 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
484 KB |
Output is correct |
2 |
Incorrect |
2 ms |
484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Incorrect |
5 ms |
636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
636 KB |
Output is correct |
2 |
Incorrect |
4 ms |
636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Incorrect |
5 ms |
636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |