이 제출은 이전 버전의 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 md ((s + e) / 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 lx node * 2
#define rx node * 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;
}
long long tree[2005][8005] , n , m ;
void Upd(ll s , ll e , ll node , ll i , ll val , ll j){
if(s == e){
tree[j][node] = val ;
return ;
}
if(i <= md)Upd(s , md , lx , i , val , j) ;
else Upd(md + 1 , e , rx , i , val , j) ;
tree[j][node] = gcd2(tree[j][lx] , tree[j][rx]) ;
}
ll query(ll s , ll e , ll node , ll l , ll r , ll lj , ll rj){
if(l <= s && e <= r){
ll ret = 0 ;
for(ll j = lj ; j <= rj ; j++)ret = gcd2(tree[j][node] , ret) ;
R ret ;
}
if(r <= md)R query(s , md , lx , l , r , lj , rj) ;
else if(l > md)R query(md + 1 , e , rx , l , r , lj , rj) ;
R gcd2(query(s , md , lx , l , r , lj , rj) , query(md + 1 , e , rx , l , r , lj , rj)) ;
}
void init(int r, int c) {
n = r , m = c ;
}
void update(int P, int Q, long long K) {
Upd(0 , m - 1 , 1 , Q , K , P) ;
}
long long calculate(int P, int Q, int U, int V) {
R query(0 , m - 1 , 1 , Q , V , P , U) ;
}
# | 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... |