이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
int c;
vector<int>K;
vector<int>X,Y,C;
vector<vector<int>>P;
int dfs(int num,int dep,vector<int>&v){
if(num+(1<<dep)>=v.size()){
return v[num];
}
else{
int t=c;
c++;
int x=dfs(num,dep+1,v);
int y=dfs(num+(1<<dep),dep+1,v);
if(x==0xE869120&&y==0xE869120){
c--;
return 0xE869120;
}
X[t]=x;
Y[t]=y;
return -t-1;
}
}
void create_circuit(int M,vector<int>A){
c=0;
K=A;
K.push_back(0);
reverse(K.begin(),K.end());
K.push_back(0);
reverse(K.begin(),K.end());
P=vector<vector<int>>(M+1);
C=vector<int>(M+1,0);
X=Y=vector<int>(A.size()*2,0xE869120);
for(int i=0;i<K.size()-1;i++){
P[K[i]].push_back(K[i+1]);
}
for(int i=0;i<=M;i++){
if(P[i].empty())continue;
for(int j=0;;j++){
if(P[i].size()<=(1<<j)){
while(P[i].size()<(1<<j))P[i].push_back(0xE869120);
for(int j=P[i].size()-1;;j--){
if(P[i][j]!=0xE869120){
swap(P[i][j],P[i].back());
break;
}
}
int l,r;
l=c;
C[i]=dfs(0,0,P[i]);
r=c;
for(int k=l;k<r;k++){
if(X[k]==0xE869120){
X[k]=C[i];
}
if(Y[k]==0xE869120){
Y[k]=C[i];
}
}
break;
}
}
}
while(!X.empty()&&X.back()==0xE869120){
X.pop_back();
Y.pop_back();
}
answer(C,X,Y);
}
컴파일 시 표준 에러 (stderr) 메시지
doll.cpp: In function 'int dfs(int, int, std::vector<int>&)':
doll.cpp:11:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | if(num+(1<<dep)>=v.size()){
| ~~~~~~~~~~~~^~~~~~~~~~
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<K.size()-1;i++){
| ~^~~~~~~~~~~
doll.cpp:45:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
45 | if(P[i].size()<=(1<<j)){
| ~~~~~~~~~~~^~~~~~~~
doll.cpp:46:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | while(P[i].size()<(1<<j))P[i].push_back(0xE869120);
| ~~~~~~~~~~~^~~~~~~
# | 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... |