#include"game.h"
#include<bits/stdc++.h>
#ifndef EVAL
#include"grader.c"
#endif
using namespace std;
typedef long long ll;
ll tree[400][400];
ll get_2(int v,int l,int r,int ql,int qr,int id){
if(qr<l||r<ql)return 0ll;
if(ql<=l&&r<=qr)
return tree[id][v];
int mid=(l+r)>>1;
return __gcd(get_2(v<<1,l,mid,ql,qr,id),get_2(v<<1|1,mid+1,r,ql,qr,id));
}
ll get(int v,int l,int r,int ql,int qr,int u,int d){
if(qr<l||r<ql)return 0ll;
if(ql<=l&&r<=qr)
return get_2(1,0,99,u,d,v);
int mid=(l+r)>>1;
return __gcd(get(v<<1,l,mid,ql,qr,u,d),get(v<<1|1,mid+1,r,ql,qr,u,d));
}
void upd_2(int v,int l,int r,int pos,ll val,int id){
if(l==r){
tree[id][v]=__gcd(tree[id][v],val);
return;
}
int mid=(l+r)>>1;
if(pos<=mid)upd_2(v<<1,l,mid,pos,val,id);
else upd_2(v<<1|1,mid+1,r,pos,val,id);
tree[id][v]=__gcd(tree[id][v],__gcd(tree[id][v<<1],tree[id][v<<1|1]));
}
void upd(int v,int l,int r,int x,int y,ll val){
if(l==r){
upd_2(1,0,99,y,val,v);
return;
}
int mid=(l+r)>>1;
if(x<=mid)upd(v<<1,l,mid,x,y,val);
else upd(v<<1|1,mid+1,r,x,y,val);
upd_2(1,0,99,y,val,v);
}
void init(int n,int m){}
void update(int x,int y,ll val){
upd(1,0,99,x,y,val);
}
ll calculate(int x,int y,int x2,int y2){
return get(1,0,99,x,x2,y,y2);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |