이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
/*
void answer(vector<int> C,vector<int> x,vector<int> y)
{
cout<<"C: ";for(auto k:C)cout<<k<<" ";cout<<endl;
int SZ=x.size();
cout<<"switches "<<endl;
for(int i=0;i<SZ;i++)
{
cout<<x[i]<<" "<<y[i]<<endl;
}
cout<<"---"<<endl;
//exit(0);
}
*/
vector<int> x,y;
vector<int> order;
bool state[1'000'000];
int open;
void solve(int run,int where)
{
//cout<<"solve "<<run<<" "<<where<<endl;
where=-where;
if(where>=open/2)
{
if(run<order.size())
{
if(state[where-1]==0)
{
x[where-1]=order[run];
state[where-1]=!state[where-1];
}
else
{
y[where-1]=order[run];
state[where-1]=!state[where-1];
}
return;
}
if(run==open-1)
{
y[where-1]=0;
return;
}
state[where-1]=!state[where-1];
return;
}
if(state[where-1]==0)
{
state[where-1]=1;
solve(run,x[where-1]);
}
else
{
state[where-1]=0;
solve(run,y[where-1]);
}
}
void create_circuit(int M, vector<int> A)
{
vector<int> C={};
for(int i=0;i<=M;i++)
C.push_back(-1);
C[0]=A[0];
A.erase(A.begin(),A.begin()+1);
open=2;
while(open<=A.size())open=open*2;
for(int i=1;i<open;i++)
{
x.push_back(-1);
y.push_back(-1);
}
for(int i=1;i<open/2;i++)
{
x[i-1]=-(2*i);
y[i-1]=-(2*i+1);
}
order=A;
//answer(C,x,y);
for(int i=0;i<open;i++)
solve(i,-1);
answer(C,x,y);
}
/*
int main()
{
create_circuit(4, {1, 2, 1,3});
}
*/
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'void solve(int, int)':
doll.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(run<order.size())
| ~~~^~~~~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:79:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | while(open<=A.size())open=open*2;
| ~~~~^~~~~~~~~~
# | 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... |