#pragma GCC optimize("O3")
#include "game.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n,m;
int st[8005][8005];
long long gcd2(long long X, long long Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
void init(int R, int C) {
n=R,m=C;
}
void update_y(int node,int l,int r,int node_x,int lx,int rx,int y,ll val){
if(l>y||r<y)
return ;
if(l==r){
if(lx==rx)st[node_x][node]=val;
else st[node_x][node]=gcd2(st[node_x<<1][node],st[(node_x<<1)+1][node]);
return ;
}
int med=((l+r)>>1);
update_y((node<<1),l,med,node_x,lx,rx,y,val);
update_y((node<<1)+1,med+1,r,node_x,lx,rx,y,val);
st[node_x][node]=gcd2(st[node_x][(node<<1)],st[node_x][(node<<1)+1]);
}
void update_x(int node,int l,int r,int x,int y,ll val){
if(l>x||r<x)
return ;
if(l!=r){
int med=((l+r)>>1);
update_x((node<<1),l,med,x,y,val);
update_x((node<<1)+1,med+1,r,x,y,val);
}
update_y(1,0,m-1,node,l,r,y,val);
}
int query_y(int node,int l,int r,int node_x,int y1,int y2){
if(l>y2||r<y1)
return 0;
if(l>=y1&&r<=y2)
return st[node_x][node];
int med=((l+r)>>1);
return gcd2(query_y((node<<1),l,med,node_x,y1,y2),query_y((node<<1)+1,med+1,r,node_x,y1,y2));
}
int query_x(int node,int l,int r,int x1,int y1,int x2,int y2){
if(l>x2||r<x1)
return 0;
if(l>=x1&&r<=x2)
return query_y(1,0,m-1,node,y1,y2);
int med=((l+r)>>1);
return gcd2(query_x((node<<1),l,med,x1,y1,x2,y2),query_x((node<<1)+1,med+1,r,x1,y1,x2,y2));
}
void update(int P, int Q, ll K) {
update_x(1,0,n-1,P,Q,K);
}
long long calculate(int P, int Q, int U, int V) {
return query_x(1,0,n-1,P,Q,U,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 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |