이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
static int c;
static vector<int>K;
static vector<int>X,Y,C;
int dfs(int num,int dep){
if(num+(1<<dep)>=K.size()){
return K[num];
}
else{
int t=c;
c++;
X[t]=dfs(num,dep+1);
Y[t]=dfs(num+(1<<dep),dep+1);
return -t-1;
}
}
void create_circuit(int M,vector<int>A){
c=0;
K=A;
X=Y=vector<int>(400000,0);
C=vector<int>(M+1,0);
for(int i=0;;i++){
if(K.size()<(1<<i)){
while(K.size()<(1<<i)){
K.push_back(-c-1);
c++;
}
c--;
K.back()=0;
break;
}
}
int cc=c;
int tt=dfs(0,0);
C=vector<int>(M+1,tt);
for(int i=0;i<cc;i++){
X[i]=-i-1;
Y[i]=tt;
}
vector<bool>B(400000,false);
int p=0;
vector<int>T;
int cnt=0;
do{
cnt++;
if(p>=0){
if(p)T.push_back(p);
p=C[p];
}
else{
if(B[-p-1]){
B[-p-1]=!B[-p-1];
p=Y[-p-1];
}
else{
B[-p-1]=!B[-p-1];
p=X[-p-1];
}
}
}while(p);
assert(A==T);
bool f=false;
for(int i=0;i<400000;i++){
f|=B[i];
}
assert(!f);
for(int i:C){
assert(-(int)X.size()<=i&&i<=M);
}
for(int i:X){
assert(-(int)X.size()<=i&&i<=M);
}
for(int i:Y){
assert(-(int)X.size()<=i&&i<=M);
}
assert(cnt<=20000000);
answer(C,X,Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int dfs(int, int)':
doll.cpp:10:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | if(num+(1<<dep)>=K.size()){
| ~~~~~~~~~~~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:28:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | if(K.size()<(1<<i)){
| ~~~~~~~~^~~~~~~
doll.cpp:29:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
29 | while(K.size()<(1<<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... |