Submission #29932

#TimeUsernameProblemLanguageResultExecution timeMemory
29932ozaslanGame (IOI13_game)C++14
10 / 100
13000 ms127020 KiB
#include <bits/stdc++.h> #include <stdio.h> #include "game.h" #define max_N 100001 long long gcd2(long long X, long long Y) { //printf("X\n"); long long tmp; while (X != Y && Y != 0) { tmp = X; X = Y; Y = tmp % Y; } return X; } long long st[2000][2000 * 4]; int sa, su; void init(int R, int C) { sa = R; su = C; } void guncelle(int dugum, int sol, int sag, int satir, int sutun, long long K) { if (sol == sag) { st[satir][dugum] = K; return; } int orta = (sol + sag) / 2; if (orta >= sutun) guncelle(dugum*2, sol, orta, satir, sutun, K); else guncelle(dugum*2+1, orta+1, sag, satir, sutun, K); st[satir][dugum] = gcd2(st[satir][dugum*2], st[satir][dugum*2+1]); } void update(int P, int Q, long long K) { guncelle(1, 0, su-1, P, Q, K); } long long sorgu(int dugum, int sol, int sag, int satir, int aSol, int aSag) { // printf("Dugum: %d, sol: %d, sag: %d, satir: %d, aSol: %d, aSag: %d\n", dugum, sol, sag, satir, aSol, aSag); if(sol > aSag || sag < aSol) return -1; if(sol >= aSol && sag <= aSag) return st[satir][dugum]; int orta = (sol + sag) / 2; long long s1 = sorgu(dugum*2, sol, orta, satir, aSol, aSag); long long s2 = sorgu(dugum*2+1, orta+1, sag, satir, aSol, aSag); if ( (s1 != -1) && (-1 != s2) ) return gcd2(s1, s2); if (s1 == -1) return s2; return s1; } long long calculate(int P, int Q, int U, int V) { /* ... */ long long ekok = sorgu(1, 0, su-1, P, Q, V); // printf("Satir: %d, s: %lld\n", P, ekok); for (int i = P+1; i <= U; i++) { long long s = sorgu(1, 0, su-1, i, Q, V); // printf("Satir: %d, s: %lld\n", i, s); ekok = gcd2(ekok, s); } return ekok; }

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...