이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ;
k = 1 ;
}
struct op{
int leftx , rightx , lefty , righty ;
ll val ;
}tree[15000005];
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[node].lefty = ++k ;
}
updatey(sy , mdy , tree[node].lefty , sx , ex , x , y , val) ;
}
else {
if(!tree[node].righty)tree[node].righty = ++k ;
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[node].leftx = ++k ;
updatex(sx , mdx , tree[node].leftx , x , y , val) ;
}
else {
if(!tree[node].rightx)tree[node].rightx = ++k ;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |