이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "game.h"
#include <bits/stdc++.h>
#pragma optimize("Ofast")
#pragma target("avx2")
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert
// #define int ll
const int MAX=22000+15;
const int N=104;
const ll inf=1e9;
const int mod=1e9+7;
const int mod1=1e9+9;
const ld eps=1e-9;
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,-1,1,-1};
mt19937 rng(21345678);
int n,m;
struct DO1{
vector<ll> t;
unordered_map<int,int> lv,rv;
DO1(){
t.pb(0);
}
void update(int v,int tl,int tr,int pos,ll x){
if(tl==tr){
t[v]=x;
return;
}
int tm=(tl+tr)/2;
if(pos<=tm){
if(!lv[v]){
lv[v]=sz(t);
t.pb(0);
}
update(lv[v],tl,tm,pos,x);
}
else{
if(!rv.count(v)){
rv[v]=sz(t);
t.pb(0);
}
update(rv[v],tm+1,tr,pos,x);
}
t[v]=0;
if(lv.count(v))t[v]=gcd(t[v],t[lv[v]]);
if(rv.count(v))t[v]=gcd(t[v],t[rv[v]]);
}
ll get(int v,int tl,int tr,int l,int r){
if(l>r||tl>r||l>tr)return 0;
if(l<=tl&&tr<=r){
return t[v];
}
int tm=(tl+tr)/2;
ll ans=0;
if(lv.count(v))ans=gcd(ans,get(lv[v],tl,tm,l,r));
if(rv.count(v))ans=gcd(ans,get(rv[v],tm+1,tr,l,r));
return ans;
}
};
struct DO2{
vector<DO1> t;
unordered_map<int,int> lv,rv;
DO2(){
t.emplace_back();
}
void new_node(){
t.emplace_back();
}
void update(int v,int tl,int tr,int posx,int posy,ll x){
if(tl==tr){
t[v].update(0,0,m,posy,x);
return;
}
int tm=(tl+tr)/2;
if(posx<=tm){
if(!lv.count(v)){
lv[v]=sz(t);
new_node();
}
update(lv[v],tl,tm,posx,posy,x);
}
else{
if(!rv.count(v)){
rv[v]=sz(t);
new_node();
}
update(rv[v],tm+1,tr,posx,posy,x);
}
ll ans=0;
if(lv.count(v))ans=gcd(ans,t[lv[v]].get(0,0,m,posy,posy));
if(rv.count(v))ans=gcd(ans,t[rv[v]].get(0,0,m,posy,posy));
t[v].update(0,0,m,posy,ans);
}
ll get(int v,int tl,int tr,int lx,int rx,int ly,int ry){
if(lx>rx||lx>tr||tl>rx)return 0;
if(lx<=tl&&tr<=rx){
return t[v].get(0,0,m,ly,ry);
}
int tm=(tl+tr)/2;
ll ans=0;
if(lv.count(v))ans=gcd(ans,get(lv[v],tl,tm,lx,rx,ly,ry));
if(rv.count(v))ans=gcd(ans,get(rv[v],tm+1,tr,lx,rx,ly,ry));
return ans;
}
}t;
void init(int R, int C) {
n=R-1;
m=C-1;
}
void update(int P, int Q, long long K) {
t.update(0,0,n,P,Q,K);
}
long long calculate(int P, int Q, int U, int V) {
int lx=min(P,U);
int rx=max(P,U);
int ly=min(Q,V);
int ry=max(Q,V);
return t.get(0,0,n,lx,rx,ly,ry);
}
컴파일 시 표준 에러 (stderr) 메시지
game.cpp:5: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
5 | #pragma optimize("Ofast")
|
game.cpp:6: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
6 | #pragma target("avx2")
|
# | 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... |