Submission #962987

#TimeUsernameProblemLanguageResultExecution timeMemory
962987n3rm1nGame (IOI13_game)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "game.h" using namespace std; int r, c; void init(int R, int C) { r = R; c = C; } map < pair < long long, long long >, long long > mp; long long gcd2(long long X, long long Y) { int ans = mp[make_pair(X, Y)]; if(ans)return ans; long long tmp; long long oldx = X, oldy = Y; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } mp[make_pair(oldx, oldy)] = X; return X; } long long t[2005][8005]; int line, ql, qr; long long query(int i, int l, int r) { if(ql > r || qr < l)return 0; if(ql <= l && r <= qr)return t[line][i]; int mid = (l + r)/2; return gcd2(query(2*i, l, mid), query(2*i+1, mid+1, r)); } int pnt; long long val; void upd(int i, int l, int r) { if(l == r) { t[line][i] = val; return; } int 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...