제출 #729492

#제출 시각아이디문제언어결과실행 시간메모리
729492Blistering_Barnacles게임 (IOI13_game)C++11
0 / 100
1 ms1108 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 ; void init(int r, int c) { n = r , m = c ; } ll tree[8005][8005] ; void updatey(ll sy , ll ey , ll nodey , ll sx , ll ex , ll nodex , ll x , ll y , ll val){ if(sy == ey){ if(sx == ex)tree[nodex][nodey] = val ; else tree[nodex][nodey] = gcd2(tree[lxx][nodey] , tree[rxx][nodey]) ; R ; } 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(ll sx , ll ex , ll nodex , ll x , ll 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(ll sy , ll ey , ll nodey , ll nodex , ll ly , ll ry){ if(sy > ry || ey < ly)R 0 ; if(ly <= sy && ey <= ry)R tree[nodex][nodey] ; R gcd2(queryy(sy , mdy , lxy , nodex , ly , ry) , queryy(mdy + 1 , ey , nodey , nodex , ly , ry)) ; } ll queryx(ll sx , ll ex , ll nodex , ll lx , ll ly , ll rx , ll ry){ if(sx > rx || ex < lx)R 0 ; if(lx <= sx && ex <= rx){ R queryy(0 , m - 1 , 1 , nodex , ly , ry) ; } R 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) { 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...