제출 #729626

#제출 시각아이디문제언어결과실행 시간메모리
729626Blistering_Barnacles게임 (IOI13_game)C++11
63 / 100
1554 ms256000 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 lxx nodex * 2 #define rxx nodex * 2 + 1 #define lxy nodey * 2 #define rxy nodey * 2 + 1 #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 ; struct op{ int leftx , rightx , lefty , righty ; ll val ; }emp; vector < op > tree ; void init(int r, int c) { n = r , m = c ; tree.pb(emp) ; tree.pb(emp) ; } deque < ll > se ; void updatey(ll sy , ll ey , ll node , ll sx , ll ex , ll x , ll y , ll val){ if(sy == ey){ if(sx == ex){ tree[node].val = val ; } else { ll op = se.front() ; se.pop_front() ; if(x <= mdx){ if(!tree[node].leftx)tree[node].leftx = op ; } else { if(!tree[node].rightx)tree[node].rightx = op ; } tree[node].val = gcd2(tree[tree[node].leftx].val , tree[tree[node].rightx].val) ; } se.pb(node) ; R ; } if(y <= mdy){ if(!tree[node].lefty){ tree.pb(emp) ; tree[node].lefty = sz(tree) - 1 ; } updatey(sy , mdy , tree[node].lefty , sx , ex , x , y , val) ; } else { if(!tree[node].righty){ tree.pb(emp) ; tree[node].righty = sz(tree) - 1 ; } updatey(mdy + 1 , ey , tree[node].righty , sx , ex , x , y , val) ; } tree[node].val = gcd2(tree[tree[node].lefty].val , tree[tree[node].righty].val) ; } void updatex(ll sx , ll ex , ll node , ll x , ll y , ll val){ if(sx != ex){ if(x <= mdx){ if(!tree[node].leftx){ tree.pb(emp) ; tree[node].leftx = sz(tree) - 1 ; } updatex(sx , mdx , tree[node].leftx , x , y , val) ; } else { if(!tree[node].rightx){ tree.pb(emp) ; tree[node].rightx = sz(tree) - 1 ; } updatex(mdx + 1 , ex , tree[node].rightx , x , y , val) ; } } updatey(0 , m - 1 , node , sx , ex , x , y , val) ; } ll queryy(ll sy , ll ey , ll node , ll ly , ll ry){ if(sy > ry || ey < ly || !node)R 0 ; if(ly <= sy && ey <= ry)R tree[node].val ; R gcd2(queryy(sy , mdy , tree[node].lefty , ly , ry) , queryy(mdy + 1 , ey , tree[node].righty , ly , ry)) ; } ll queryx(ll sx , ll ex , ll node , ll lx , ll ly , ll rx , ll ry){ if(sx > rx || ex < lx || !node)R 0 ; if(lx <= sx && ex <= rx){ R queryy(0 , m - 1 , node , ly , ry) ; } R gcd2(queryx(sx , mdx , tree[node].leftx , lx , ly , rx , ry) , queryx(mdx + 1 , ex , tree[node].rightx , lx , ly , rx , ry)) ; } void update(int P, int Q, long long K) { updatex(0 , n - 1 , 1 , P , Q , K) ; se.clear() ; } long long calculate(int P, int Q, int U, int V) { R 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...