제출 #194154

#제출 시각아이디문제언어결과실행 시간메모리
194154juanmartinez111Paint By Numbers (IOI16_paint)C++14
0 / 100
1135 ms524292 KiB
#include "paint.h" #include <cstdlib> using namespace std; int visi[104]; int minimo=0; long long cx=0,n; vector<int>paredes; string nw=""; void rec(int pos,int cnt){ if(cnt ==cx){ while((int)nw.size()<n)nw.push_back('_'); vector<int>posible; int cnt=0; for(int i=0;i<n;i++){ if(nw[i]=='X')cnt++; if(cnt!=0 and nw[i]=='_' or i+1==n){ posible.push_back(cnt); cnt=0; } } if(posible==paredes){ for(int i=0;i<nw.size();i++){ if(nw[i]=='X'){ if(visi[i]==0)visi[i]=1; else if(visi[i]!=1)visi[i]=3; } if(nw[i]=='_'){ if(visi[i]==0)visi[i]=2; else if(visi[i]!=2)visi[i]=3; } } } } else{ nw+='X'; rec(pos+1,cnt+1); nw.pop_back(); nw+='_'; rec(pos+1,cnt); nw.pop_back(); } } std::string solve_puzzle(std::string s, std::vector<int> c) { string a=""; n=s.size(); for(auto it:c)paredes.push_back(it); for(int i=0;i<c.size();i++)cx+=c[i]; rec(0,0); for(int i=0;i<s.size();i++){ if(visi[i]==1)a.push_back('X'); else if(visi[i]==2)a.push_back('_'); else a.push_back('?'); } return a; }

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

paint.cpp: In function 'void rec(int, int)':
paint.cpp:17:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
             if(cnt!=0 and nw[i]=='_' or i+1==n){
                ~~~~~~~^~~~~~~~~~~~~~
paint.cpp:23:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<nw.size();i++){
                         ~^~~~~~~~~~
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:48:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<c.size();i++)cx+=c[i];
                 ~^~~~~~~~~
paint.cpp:50:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++){
                 ~^~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...