제출 #1314806

#제출 시각아이디문제언어결과실행 시간메모리
1314806kawhiet게임 (IOI13_game)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; struct SegmentTree { int n; vector<long long> t; SegmentTree(int _n) { n = _n; t.resize(4 * n); } void update(int id, int tl, int tr, int i, long long v) { if (tl == tr) { t[id] = v; return; } int x = 2 * id + 1, y = x + 1, tm = (tl + tr) / 2; if (i <= tm) { update(x, tl, tm, i, v); } else { update(y, tm + 1, tr, i, v); } t[id] = gcd(t[x], t[y]); } long long get(int id, int tl, int tr, int l, int r) { if (r < tl || tr < l) return 0LL; if (l <= tl && tr <= r) { return t[id]; } int x = 2 * id + 1, y = x + 1, tm = (tl + tr) / 2; return gcd(get(x, tl, tm, l, r), get(y, tm + 1, tr, l, r)); } void update(int i, int v) { update(0, 0, n - 1, i, v); } long long get(int l, int r) { return get(0, 0, n - 1, l, r); } }; int n, m; vector<SegmentTree> a; void init(int R, int C) { n = R; m = C; for (int i = 0; i < n; i++) { a.push_back(SegmentTree(m)); } } void update(int i, int j, long long k) { a[i].update(j, k); } long long calculate(int p, int q, int u, int v) { long long ans = 0; for (int i = p; i <= u; i++) { ans = gcd(ans, a[i].get(q, v)); } return ans; }
#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...