이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*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=400005;
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){
int n=SZ(a);
REP(i,m+1) C.pb(-1);
int N=2;
while(N<n){
N<<=1;
++lg;
}
REP(i,n) order.pb(i);
REP(i,n) rev[i]=revbit(i);
sort(ALL(order),cmp);
r.resize(SZ(order));
REP(i,n) r[order[i]]=i;
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) continue;
idx[i]=pt++;
}
X.resize(pt);
Y.resize(pt);
for(int i=1;i<N;i++){
if(L[i]==R[i]-2){
X[i-1]=a[r[L[i]]];
if(L[i]+1>=n) Y[i-1]=-1;
else Y[i-1]=a[r[L[i]+1]];
continue;
}
int mid=(L[i]+R[i])/2;
X[i-1]=-1-idx[i<<1];
if(mid>=n) Y[i-1]=-1;
else Y[i-1]=-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 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |