# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1090469 |
2024-09-18T11:59:08 Z |
vjudge1 |
Game (IOI13_game) |
C++17 |
|
1 ms |
1120 KB |
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ar array
ll gcd2(ll X, ll Y) {
ll tmp;
while (X != Y && Y != 0) {
tmp = X;
X = Y;
Y = tmp % Y;
}
return X;
}
struct Seggy{
vector<ll> s;
void init(int n){
s.resize(3 * 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] = gcd2(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 gcd2(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(3 * n);
for(auto &u: seg)u.init(m);
}
void upd(int k,int tl,int tr,int p, ar<int, 2> v){
if(tl != tr){
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);
}
seg[k].upd(1, 0, m - 1, v[0], v[1]);
}
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 gcd2(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) {
// cout<<gcd(0, 0)<<'\n';
n = R + 10, m = C + 10;
Seggy2D::init(n, m);
}
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:89: warning: "int" redefined
89 | #define int signed
|
game.cpp:7: note: this is the location of the previous definition
7 | #define int long long
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
352 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1120 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
356 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
436 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
1116 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |