Submission #1039445

#TimeUsernameProblemLanguageResultExecution timeMemory
1039445ArthuroWichGame (IOI13_game)C++17
37 / 100
509 ms30928 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; #define int long long int int gcd2(int X, int Y) { int tmp; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } return X; } int seg[100][4*100005]; void update(int n, int l, int r, int i, int v, int id) { if (l == r) { seg[id][n] = v; } else { int m = (l+r)/2; if (l <= i && i <= m) { update(2*n, l, m, i, v, id); } else { update(2*n+1, m+1, r, i, v, id); } seg[id][n] = gcd2(seg[id][2*n], seg[id][2*n+1]); } } int query(int n, int l, int r, int a, int b, int id) { if (b < l || r < a) { return 0; } else if (a <= l && r <= b) { return seg[id][n]; } else { int m = (l+r)/2; return gcd2(query(2*n, l, m, a, b, id), query(2*n+1, m+1, r, a, b, id)); } } void init(int32_t R, int32_t C) { } void update(int32_t P, int32_t Q, int K) { update(1, 0, 100000, Q, K, P); } int calculate(int32_t P, int32_t Q, int32_t U, int32_t V) { int x = 0; for (int i = P; i <= U; i++) { x = gcd2(x, query(1, 0, 100000, Q, V, i)); } return x; }
#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...