이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
#define ll int
#define pb push_back
#define ld long double
#define F first
#define S second
#define mp make_pair
#define pii pair<ll,ll>
using namespace :: std;
const ll maxn=6e5+500;
const ll inf=1e9+900;
const ll mod=1e9+7;
ll cnt=-2;
ll outx[maxn];
ll outy[maxn];
bool yeki(vector<ll> vec){
for(ll i=1;i<vec.size();i++)if(vec[i]!=vec[0])return 0;
return 1;
}
void bild(ll node,vector<ll> a){
ll n=a.size();
if((n&(-n))!=n){
reverse(a.begin(),a.end());
while(1){
a.pb(node);
n=a.size();
if((n&(-n))==n)break;
}
reverse(a.begin(),a.end());
}
vector<ll> l,r;
for(ll i=0;i<a.size();i++){
if(i&1){
r.pb(a[i]);
}else{
l.pb(a[i]);
}
}
if(yeki(l)){
outx[-node]=l[0];
}else{
outx[-node]=cnt--;
bild(outx[-node],l);
}
if(yeki(r)){
outy[-node]=r[0];
}else{
outy[-node]=cnt--;
bild(outy[-node],r);
}
}
ll rev(ll a,ll v){
vector<ll> b;
for(ll i=0;i<30;i++){
if((1<<i)<=v){
b.pb((a>>i)&1);
}
}
reverse(b.begin(),b.end());
ll ans=0;
for(ll i=0;i<b.size();i++){
ans+=(1<<i)*b[i];
}
return ans;
}
vector<ll> okKon(vector<ll> b){
ll n=b.size();
if((n&(-n))==n)return b;
ll v=n;
while((v&(-v))!=v)v++;
ll o=v-n;
vector<ll> ans;
ans.resize(v);
fill(ans.begin(),ans.end(),0);
for(ll i=0;i<o;i++){
ans[(rev(i,v))]=-1;
}
ll cnt=0;
for(auto t:b){
while(ans[cnt]==-1)cnt++;
ans[cnt]=t;
cnt++;
}
return ans;
}
void create_circuit(int m,vector<int> a){
a.pb(0);
ll n=a.size();
vector<ll> c,x,y;
c.resize(m+1);
vector<ll> b;
for(ll i=1;i<n;i++)b.pb(a[i]);
fill(c.begin(),c.end(),-1);
c[0]=a[0];
b=okKon(b);
bild(-1,b);
for(ll i=-1;i>cnt;i--){
x.pb(outx[-i]);
y.pb(outy[-i]);
}
/*
for(auto v:c)cout<<v<<' ';
cout<<endl;
for(auto v:x)cout<<v<<' ';
cout<<endl;
for(auto v:y)cout<<v<<' ';
cout<<endl;
*/
answer(c,x,y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'bool yeki(std::vector<int>)':
doll.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(ll i=1;i<vec.size();i++)if(vec[i]!=vec[0])return 0;
| ~^~~~~~~~~~~
doll.cpp: In function 'void bild(int, std::vector<int>)':
doll.cpp:39:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(ll i=0;i<a.size();i++){
| ~^~~~~~~~~
doll.cpp: In function 'int rev(int, int)':
doll.cpp:68:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | for(ll i=0;i<b.size();i++){
| ~^~~~~~~~~
# | 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... |