Submission #962889

#TimeUsernameProblemLanguageResultExecution timeMemory
962889n3rm1nGame (IOI13_game)C++17
37 / 100
731 ms129880 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; long long r, c; void init(int R, int C) { r = R; c = C; } long long gcd2(long long X, long long Y) { long long tmp; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } return X; } long long t[105][400005]; long long line, ql, qr; long long query(long long i, long long l, long long r) { if(ql > r || qr < l)return 0; if(ql <= l && r <= qr)return t[line][i]; long long mid = (l + r)/2; return gcd2(query(2*i, l, mid), query(2*i+1, mid+1, r)); } long long pnt; long long val; void upd(long long i, long long l, long long r) { if(l == r) { t[line][i] = val; return; } long long mid = (l + r)/2; if(pnt <= mid)upd(2*i, l, mid); else upd(2*i+1, mid+1, r); t[line][i] = gcd2(t[line][2*i], t[line][2*i+1]); } void update(int P, int Q, long long K) { P ++; Q ++; line = P; pnt = Q; val = K; upd(1, 1, c); } long long calculate(int P, int Q, int U, int V) { P ++; Q ++; U ++; V ++; long long ans = 0; ql = Q; qr = V; for (line = P; line <= U; ++ line) ans = gcd2(ans, query(1, 1, c)); 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...