#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ar array
struct Seggy{
vector<ll> s;
void init(int n){
s.resize(4 * n, 0);
}
void upd(int k,int tl,int tr,int p,ll v){
if(tl == tr){
s[k] = v;
return;
}
int tm = (tl + tr) / 2;
if(p <= tm)upd(k *2, tl, tm, p, v);
else upd(k *2 + 1, tm + 1, tr, p, v);
s[k] = __gcd(s[k * 2], s[k * 2 + 1]);
}
ll qry(int k,int tl,int tr,int l,int r){
if(l > tr || tl > r)return 0;
if(l <= tl && tr <= r)return s[k];
int tm = (tl +tr) / 2;
return __gcd(qry(k * 2,tl, tm, l, r), qry(k *2 + 1, tm + 1, tr, l, r));
}
};
namespace Seggy2D{
vector<Seggy> seg;
int n, m;
void init(int _n,int _m){
n = _n, m = _m;
seg.resize(4 * n);
for(auto &u: seg)u.init(m);
}
void upd(int k,int tl,int tr,int p, ar<int, 2> v){
seg[k].upd(1, 0, m - 1, v[0], v[1]);
if(tl == tr)return;
int tm = (tl + tr) / 2;
if(p <= tm)upd(k * 2, tl, tm, p, v);
else upd(k * 2 + 1, tm + 1, tr, p, v);
}
int qry(int k,int tl,int tr, int l,int r, ar<int, 2> v){
if(l > tr || tl > r)return 0;
if(l <= tl && tr <= r)return seg[k].qry(1,0 ,m - 1, v[0], v[1]);
int tm = (tl + tr) / 2;
return __gcd(qry(k *2 ,tl, tm, l, r, v), qry(k *2 + 1, tm + 1, tr , l,r ,v ));
}
};
int n, m;
void init(signed R, signed C) {
n = R, m = C;
Seggy2D::init(R, C);
}
void update(signed P, signed Q, long long K) {
Seggy2D::upd(1, 0, n - 1, P, {Q, K});
}
long long calculate(signed P, signed Q, signed U, signed V) {
return Seggy2D::qry(1, 0, n - 1, P, U, {Q, V});
}
#define int signed
Compilation message
game.cpp:76: warning: "int" redefined
76 | #define int signed
|
game.cpp:7: note: this is the location of the previous definition
7 | #define int long long
|
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1624 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1628 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1628 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |