제출 #542816

#제출 시각아이디문제언어결과실행 시간메모리
542816Sho10자동 인형 (IOI18_doll)C++17
0 / 100
169 ms262144 KiB
#include <iostream> #include <vector> #include "doll.h" #define MIN(a, b) (((a) < (b)) ? (a) : (b)) int const nmax = 400000; using namespace std; int leftp[nmax+1]; int rightp[nmax+1]; int cng[nmax+1]; int switches=0,added=0; int creategraph(int nodes,int realnodes){ if(realnodes==0){ return -1; } if(nodes==1){ return (added++); } int centr=-(++switches); leftp[-centr]=creategraph(nodes/2,realnodes-MIN(nodes/2,realnodes)); rightp[-centr]=creategraph(nodes/2,MIN(nodes/2,realnodes)); return centr; } std::vector<int>dest; int real[nmax+1]; int dfs(int node){ if(node>=0){ return node; }else { cng[-node]=(!cng[-node]); if(cng[-node]==1){ dfs(leftp[-node]); }else dfs(rightp[-node]); } } void create_circuit(int M,vector<int>A){ vector<int>C(M+1); C[0]=-1; for(int i=1;i<=M;i++) { C[i]=-1; } for(int i=0;i<A.size();i++) { dest.push_back(A[i]); } dest.push_back(0); int nodes=1; while(nodes<dest.size()){ nodes*=2; } creategraph(nodes,dest.size()); for(int i=0;i<dest.size();i++) { real[dfs(-1)]=dest[i]; } vector<int>X(switches),Y(switches); for(int k=1;k<=switches;k++) { X[k-1]=leftp[k]; Y[k-1]=rightp[k]; if(X[k-1]>=0){ X[k-1]=real[X[k-1]]; } if(Y[k-1]>=0){ Y[k-1]=real[Y[k-1]]; } } answer(C,X,Y); }

컴파일 시 표준 에러 (stderr) 메시지

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:42:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 | for(int i=0;i<A.size();i++)
      |             ~^~~~~~~~~
doll.cpp:48:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 | while(nodes<dest.size()){
      |       ~~~~~^~~~~~~~~~~~
doll.cpp:52:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 | for(int i=0;i<dest.size();i++)
      |             ~^~~~~~~~~~~~
doll.cpp: In function 'int dfs(int)':
doll.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...