Submission #1090955

#TimeUsernameProblemLanguageResultExecution timeMemory
1090955RiverFlowGame (IOI13_game)C++14
27 / 100
502 ms40016 KiB
#include "game.h" #include <bits/stdc++.h> #define nl "\n" #define no "NO" #define yes "YES" #define fi first #define se second #define vec vector #define task "main" #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin()) using namespace std; template<typename U, typename V> bool maxi(U &a, V b) { if (a < b) { a = b; return 1; } return 0; } template<typename U, typename V> bool mini(U &a, V b) { if (a > b) { a = b; return 1; } return 0; } const int N = (int)2e5 + 9; const int mod = (int)1e9 + 7; struct IT { int n; vec<long long> t; IT () {}; IT (int _n) { n = _n; t.resize(4 * n + 7); } void upd(int id, int l, int r, int p, long long v) { if (l == r) return void(t[id] = v); int m = (l + r) >> 1; if (p <= m) upd(id << 1, l, m, p, v); else upd(id << 1 | 1, m + 1, r, p, v); t[id] = __gcd(t[id << 1], t[id << 1 | 1]); } long long get(int id, int l, int r, int u, int v) { if (l > v or r < u) return 0; if (l >= u and r <= v) return t[id]; int m = (l + r) >> 1; return __gcd(get(id << 1, l, m, u, v), get(id << 1 | 1, m + 1, r, u, v)); } }; namespace SUB2 { int n, m; IT st[10]; void init(int _n, int _m) { n = _n; m = _m; FOR(i, 0, n - 1) st[i] = IT(m); } void upd(int x, int y, long long k) { ++y; st[x].upd(1, 1, m, y, k); } long long query(int x, int y, int u, int v) { ++y, ++v; long long ans = 0; for(int i = x; i <= u; ++i) { ans = __gcd(ans, st[i].get(1, 1, m, y, v)); } return ans; } }; int n, m; bool sub2 = 0; void init(int R, int C) { n = R, m = C; if (n <= 10 and m <= (int)1e5) { sub2 = 1; SUB2::init(n, m); } } void update(int P, int Q, long long K) { if (sub2) { SUB2::upd(P, Q, K); return ; } } long long calculate(int P, int Q, int U, int V) { if (sub2) { return SUB2::query(P, Q, U, V); } return 0; }
#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...