제출 #101574

#제출 시각아이디문제언어결과실행 시간메모리
101574UtahaMechanical Doll (IOI18_doll)C++14
0 / 100
2 ms332 KiB
/*input */ #include <bits/stdc++.h> #include "doll.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } //}}} const ll maxn=1000005; const ll maxlg=__lg(maxn)+2; const ll INF64=8000000000000000000LL; const int INF=0x3f3f3f3f; const ll MOD=ll(1e9+7); const double PI=acos(-1); //const ll p=880301; //const ll P=31; int lg=1; int revbit(int n){ int ret=0; REP(i,lg) if(n&(1<<i)){ ret^=(1<<(lg-1-i)); } return ret; } int rev[maxn]; bool cmp(int i,int j){ return rev[i]<rev[j]; } vector<int> C,X,Y; int pt=1; int L[maxn],R[maxn]; vector<int> order; vector<int> r; int idx[maxn]; void create_circuit(int m,vector<int> a){ if(SZ(a)==1){ C.resize(m+1); REP(i,SZ(C)) C[i]=0; C[0]=a[0]; C[a[0]]=0; answer(C,X,Y); return; } a.pb(0); int n=SZ(a)-1; REP(i,m+1) C.pb(-1); int N=2; while(N<n+1){ N<<=1; ++lg; } REP(i,n) order.pb(i); order.pb(N-1); REP(i,N) rev[i]=revbit(i); sort(ALL(order),cmp); r.resize(SZ(order)); // for(int i:order) cout<<i<<' '; // cout<<endl; REP(i,SZ(order)) r[order[i]]=i; // cout<<"N:"<<N<<'\n'; L[1]=0;R[1]=N; for(int i=1;i<N/2;i++){ int mid=(L[i]+R[i])/2; L[i<<1]=L[i];R[i<<1]=mid; L[(i<<1)|1]=mid;R[(i<<1)|1]=R[i]; } int pt=0; for(int i=1;i<N;i++){ if(L[i]>=n&&R[i]!=N) continue; idx[i]=pt++; } X.resize(pt); Y.resize(pt); // cout<<r[N-1]<<' '<<a[n-1]<<'\n'; for(int i=1;i<N;i++){ if(L[i]>=n&&R[i]!=N) continue; if(L[i]==R[i]-2){ if(L[i]<n) X[idx[i]]=a[r[L[i]]]; else X[idx[i]]=-1; if(L[i]+1>=n&&R[i]!=N) Y[idx[i]]=-1; else if(L[i]+1==N-1){ Y[idx[i]]=0; } else Y[idx[i]]=a[r[L[i]+1]]; continue; } int mid=(L[i]+R[i])/2; X[idx[i]]=-1-idx[i<<1]; if(R[i]!=N&&mid>=n) Y[idx[i]]=-1; else Y[idx[i]]=-1-idx[(i<<1)|1]; } answer(C,X,Y); // REP(i,SZ(C)) cout<<C[i]<<" \n"[i==SZ(C)-1]; // cout<<SZ(X)<<'\n'; // REP(i,SZ(X)) cout<<-1-i<<' '<<X[i]<<' '<<Y[i]<<'\n'; } // vector<int> meow; // int main() // { // int n,m; // cin>>m>>n; // meow.resize(n); // REP(i,n) cin>>meow[i]; // create_circuit(m,meow); // return 0; // }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...