Submission #93862

#TimeUsernameProblemLanguageResultExecution timeMemory
93862alexpetrescuGame (IOI13_game)C++14
10 / 100
13067 ms135780 KiB
#include "game.h" #include <cstring> #include <algorithm> long long ***rmq; int nrlin, nrcol, lg2[100001]; 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; } void init(int R, int C) { nrlin = R; nrcol = C; int n = std::max(nrlin, nrcol); for (int i = 2; i <= n; i++) if ((1 << (lg2[i - 1] + 1)) == i) lg2[i] = lg2[i - 1] + 1; else lg2[i] = lg2[i - 1]; rmq = new long long**[nrlin]; for (int i = 0; i < nrlin; i++) { rmq[i] = new long long*[lg2[nrcol] + 1]; for (int j = 0; j <= lg2[nrcol]; j++) { rmq[i][j] = new long long[nrcol]; for (int b = 0; b < nrcol; b++) rmq[i][j][b] = 0; } } } void update(int P, int Q, long long K) { rmq[P][0][Q] = K; for (int b = 1; b <= lg2[nrcol]; b++) for (int j = (1 << b) - 1; j < nrcol; j++) rmq[P][b][j] = gcd2(rmq[P][b - 1][j], rmq[P][b - 1][j - (1 << (b - 1))]); } long long calculate(int P, int Q, int U, int V) { int b = lg2[V - Q + 1]; Q += (1 << b) - 1; long long ans = 0; for (int i = P; i <= U; i++) ans = gcd2(ans, gcd2(rmq[i][b][V], rmq[i][b][Q])); return ans; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
#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...