제출 #828555

#제출 시각아이디문제언어결과실행 시간메모리
828555Blistering_Barnacles게임 (IOI13_game)C++11
36 / 100
1144 ms133612 KiB
#include "game.h" //Billions of bilious blue blistering barnacles in a thundering typhoon! #pragma GCC optimize("Ofast,fast-math,unroll-loops") #pragma GCC target("avx2,fma") #include<bits/stdc++.h> #define fast ios::sync_with_stdio(0) , cin.tie(0) #define F first #define S second #define pb push_back #define vll vector< ll > #define vi vector< int > #define pll pair< ll , ll > #define pi pair< int , int > #define all(s) s.begin() , s.end() #define sz(s) s.size() #define str string #define mdx ((sx + ex) / 2) #define mdy ((sy + ey) / 2) #define mid ((l + r) / 2) #define msdp(dp) memset(dp , -1 , sizeof dp) #define mscl(dp) memset(dp , 0 , sizeof dp) #define C continue #define R return #define B break #define br(dosomething) {dosomething; break;} #define co(dosomething) {dosomething ; continue;} using namespace std; typedef long long ll; 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; } ll n , m , k ; void init(int r, int c) { n = r , m = c ; } #define lxx nodex * 2 #define rxx nodex * 2 + 1 #define lxy nodey * 2 #define rxy nodey * 2 + 1 ll tree[8005][8005] ; void updatey(int sy, int ey, int nodey, int sx, int ex, int nodex, int x, int y, ll val){ if(sy == ey){ if(sx == ex)tree[nodex][nodey] = val; else tree[nodex][nodey] = gcd2(tree[lxx][nodey], tree[rxx][nodey]); return; } if(y <= mdy)updatey(sy, mdy, lxy, sx, ex, nodex, x, y, val); else updatey(mdy + 1, ey, rxy, sx, ex, nodex, x, y, val); tree[nodex][nodey] = gcd2(tree[nodex][lxy], tree[nodex][rxy]); } void updatex(int sx, int ex, int nodex, int x, int y, ll val){ if(sx != ex){ if(x <= mdx)updatex(sx, mdx, lxx, x, y, val); else updatex(mdx + 1, ex, rxx, x, y, val); } updatey(0, m - 1, 1, sx, ex, nodex, x, y, val); } ll queryy(int sy, int ey, int nodey, int nodex, int ly, int ry){ if(sy > ry || ey < ly)return 0; if(ly <= sy && ey <= ry)return tree[nodex][nodey]; return gcd2(queryy(sy, mdy, lxy, nodex, ly, ry), queryy(mdy + 1, ey, rxy, nodex, ly, ry)); } ll queryx(int sx, int ex, int nodex, int lx, int ly, int rx, int ry){ if(sx > rx || ex < lx)return 0; if(lx <= sx && ex <= rx){ return queryy(0, m - 1, 1, nodex, ly, ry); } return gcd2(queryx(sx, mdx, lxx, lx, ly, rx, ry), queryx(mdx + 1, ex, rxx, lx, ly, rx, ry)); } void update(int P, int Q, long long K) { updatex(0 , n - 1 , 1 , P , Q , K) ; } long long calculate(int P, int Q, int U, int V) { return queryx(0 , n - 1 , 1 , P , Q , U , V) ; }
#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...