Submission #384040

#TimeUsernameProblemLanguageResultExecution timeMemory
384040alireza_kavianiGame (IOI13_game)C++11
37 / 100
13095 ms9060 KiB
#include <bits/stdc++.h> #include "game.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define X first #define Y second #define SZ(x) ll(x.size()) 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; } vector<pair<ll , pii>> vec; void init(int R, int C) { // } void update(int P, int Q, long long K) { for(int i = 0 ; i < SZ(vec) ; i++){ if(vec[i].Y.X == P && vec[i].Y.Y == Q){ vec[i].X = K; return; } } int ptr = SZ(vec); vec.push_back({K , {P , Q}}); while(ptr > 0 && vec[ptr].Y < vec[ptr - 1].Y) swap(vec[ptr] , vec[ptr - 1]) , ptr--; } long long calculate(int P, int Q, int U, int V) { ll res = 0; for(pair<ll , pii> i : vec){ if(P <= i.Y.X && i.Y.X <= U && Q <= i.Y.Y && i.Y.Y <= V) res = gcd2(res , i.X); } return 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...