# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551082 | tatyam | Game (IOI13_game) | C++17 | 2068 ms | 256000 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;
using u64 = uint64_t;
u32 R, C;
struct DynamicSegTree2D{
unordered_map<u32, unordered_map<u32, u64>> seg;
void set(u32 i, u32 j, u64 x){
seg[i][j] = x;
for(int jj = j; jj >>= 1; ) seg[i][jj] = gcd(seg[i][jj << 1], seg[i][jj << 1 | 1]);
for(int ii = i; ii >>= 1; ) seg[ii][j] = gcd(seg[ii << 1][j], seg[ii << 1 | 1][j]);
for(int ii = i; ii >>= 1; ){
auto& s = seg[ii];
for(int jj = j; jj >>= 1; ) s[jj] = gcd(s[jj << 1], s[jj << 1 | 1]);
}
}
u64 get(const unordered_map<u32, u64>& s, u32 j) const {
auto p = s.find(j);
if(p == s.end()) return 0;
return p->second;
}
u64 get(u32 i, u32 l, u32 r) const {
auto p = seg.find(i);
if(p == seg.end()) return 0;
auto& s = p->second;
u64 ans = 0;
while(l < r){
if(l & 1) ans = gcd(ans, get(s, l++));
if(r & 1) ans = gcd(ans, get(s, --r));
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |