Submission #1090469

#TimeUsernameProblemLanguageResultExecution timeMemory
1090469vjudge1Game (IOI13_game)C++17
0 / 100
1 ms1120 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...