# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
194154 | juanmartinez111 | Paint By Numbers (IOI16_paint) | C++14 | 1135 ms | 524292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |