제출 #960372

#제출 시각아이디문제언어결과실행 시간메모리
960372shenfe1게임 (IOI13_game)C++17
80 / 100
3054 ms256000 KiB
#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 binpow(int a,int n){ if(!n)return 1; if(n%2==1)return a*binpow(a,n-1)%mod; int k=binpow(a,n/2); return k*k%mod; } 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; } int n,m; struct DO1{ vector<ll> t; vector<int> lv,rv; DO1(){ t.pb(0); lv.pb(0); rv.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); lv.pb(0); rv.pb(0); } update(lv[v],tl,tm,pos,x); } else{ if(!rv[v]){ rv[v]=sz(t); t.pb(0); lv.pb(0); rv.pb(0); } update(rv[v],tm+1,tr,pos,x); } t[v]=0; if(lv[v])t[v]=gcd(t[v],t[lv[v]]); if(rv[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[v])ans=gcd(ans,get(lv[v],tl,tm,l,r)); if(rv[v])ans=gcd(ans,get(rv[v],tm+1,tr,l,r)); return ans; } }; struct DO2{ vector<DO1> t; vector<int> lv,rv; DO2(){ t.emplace_back(); lv.pb(0); rv.pb(0); } void new_node(){ t.emplace_back(); lv.pb(0); rv.pb(0); } 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[v]){ lv[v]=sz(t); new_node(); } update(lv[v],tl,tm,posx,posy,x); } else{ if(!rv[v]){ rv[v]=sz(t); new_node(); } update(rv[v],tm+1,tr,posx,posy,x); } ll ans=0; if(lv[v])ans=gcd(ans,t[lv[v]].get(0,0,m,posy,posy)); if(rv[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[v])ans=gcd(ans,get(lv[v],tl,tm,lx,rx,ly,ry)); if(rv[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 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...