#include<bits/stdc++.h>
#define ll long long
#include "game.h"
using namespace std;
int r1,c1;
ll gcd2(ll X, ll Y) {
long long tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
ll t[2*2060][2*2060];
void init(int R, int C) {
r1 = R;c1 = C;
/* ... */
}
ll val;
void upd_y(int vx,int lx,int rx,int vy,int ly,int ry,int x,int y) {
if (ly == ry) {
if (lx == rx) t[vx][vy] = val;
else t[vx][vy] = gcd2(t[vx*2][vy],t[vx*2+1][vy]);
}else {
int tm = (ly + ry)/2;
if (y <= tm)
upd_y(vx,lx,rx,vy*2,ly,tm,x,y);
else
upd_y(vx,lx,rx,vy*2+1,tm,ry,x,y);
t[vx][vy] = gcd2(t[vx][vy*2],t[vx][vy*2+1]);
}
}
void upd_x(int vx,int lx,int rx,int x,int y) {
if (lx != rx) {
int tm = (lx + rx)/2;
if (x <= tm)
upd_x(vx*2,lx,tm,x,y);
else upd_x(vx*2+1,tm+1,rx,x,y);
}
upd_y(vx,lx,rx,1,0,c1-1,x,y);
}
int LX,LY,RX,RY;
ll get_y(int vx,int lx,int rx,int vy,int ly,int ry) {
if (LY > ry || RY < ly) return 0;
if (ly == ry) {
if (lx == rx) return t[vx][vy];
else return gcd2(t[vx*2][vy],t[vx*2+1][vy]);
}else {
int tm = (ly + ry)/2;
// if (y <= tm)
// return 0;
return gcd2(get_y(vx,lx,rx,vy*2,ly,tm),get_y(vx,lx,rx,vy*2+1,tm,ry));
//t[vx][vy] = gcd2(t[vx][vy*2],t[vx][vy*2+1]);
}
}
ll get_x(int vx,int lx,int rx) {
if (LX > rx || RX < lx) return 0;
if (lx != rx) {
int tm = (lx + rx)/2;
return gcd2(get_x(vx*2,lx,tm),get_x(vx*2+1,tm+1,rx));
}else return get_y(vx,lx,rx,1,0,c1-1);
// upd_y(vx,lx,rx,vy,ly,ry,x,y);
}
void update(int P, int Q, long long K) {
val = K;
upd_x(1,0,r1-1,P,Q);
/* ... */
}
long long calculate(int P, int Q, int U, int V) {
LX = P; LY = Q;
RX = U; RY = V;
return get_x(1,0,r1-1);
/* ... */
return 42;
}
Compilation message
grader.c: In function 'int main()':
grader.c:25:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
25 | while(res != 1);
| ^~~~~
grader.c:26:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
26 | res = fscanf(f, "%d", &C);
| ^~~
grader.c:27:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
27 | while(res != 1);
| ^~~~~
grader.c:28:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
28 | res = fscanf(f, "%d", &N);
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Runtime error |
166 ms |
256004 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Runtime error |
171 ms |
256004 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
175 ms |
256004 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
166 ms |
256004 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Runtime error |
161 ms |
256004 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |