제출 #987604

#제출 시각아이디문제언어결과실행 시간메모리
987604happypotato게임 (IOI13_game)C++17
37 / 100
13099 ms37468 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") ll sto[2001][2001]; ll gcd(ll a, ll b) { if (a <= 2000 && b <= 2000) return sto[a][b]; while (b) b ^= a ^= b ^= a %= b; return a; } void init(int R, int C) { for (int i = 0; i <= 2000; i++) { for (int j = 0; j <= 2000; j++) { sto[i][j] = gcd(i, j); } } } vector<pair<pii, ll>> v; void update(int P, int Q, long long K) { for (auto it = v.begin(); it != v.end(); ++it) { if (it->ff.ff == P && it->ff.ss == Q) { v.erase(it); break; } } v.pb({{P, Q}, K}); // for (pair<pii, ll> &x : v) cerr << x.ff.ff << ' ' << x.ff.ss << ' ' << x.ss << endl; // cerr << endl; } long long calculate(int P, int Q, int U, int V) { if (P > U) swap(P, U); if (Q > V) swap(Q, V); ll res = 0; for (pair<pii, ll> &x : v) { if (P <= x.ff.ff && x.ff.ff <= U && Q <= x.ff.ss && x.ff.ss <= V) { res = gcd(res, x.ss); if (res == 1) break; } } 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...