Submission #1263775

#TimeUsernameProblemLanguageResultExecution timeMemory
1263775aren_danceGame (IOI13_game)C++20
10 / 100
13091 ms321536 KiB
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <set> #include <map> #include "game.h" #define ll long long using namespace std; vector<vector<vector<ll>>> a; ll gcd(ll x,ll y) { if (x > y) { swap(x, y); } if (x == 0) { return y; } if (y % x == 0) { return x; } return gcd(y%x,x); } void init(int R, int C) { a.resize(R); for (int i = 0;i < R;++i) { a[i].resize(C); for (int j = 0;j < C;++j) { a[i][j].resize(11); for (int k = 0;k < 11;++k) { a[i][j][k] = 0; } } } } void update(int P, int Q, long long K) { a[P][Q][0] = K; for (int j = 1;j < 11;++j) { for (int i = 0;i < a[P].size();++i) { a[P][i][j] = gcd(a[P][i][j-1],a[P][min(i+(1<<(j-1)),int(a[P].size()) - 1)][j - 1]); } } } long long calculate(int P, int Q, int U, int V) { ll answ = 0; ll x = log2(V - Q + 1); for (int i = P;i <= U;++i) { answ = gcd(answ, gcd(a[i][Q][x],a[i][V-(1<<x)+1][x])); } return answ; }
#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...