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>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int maxn=21;
bool boja[maxn];
int n, k;
vector < int > v;
bool bijela[maxn];
bool crna[maxn];
void probaj(){
int br=0, pos=0;
for(int i=0; i<n; i++){
if(boja[i]){
br++;
}
else{
if(br){
if(pos<k && v[pos]==br){
pos++;
}
else{
return;
}
br=0;
}
}
}
if(br){
if(pos<k && v[pos]==br){
pos++;
}
else{
return;
}
}
if(pos!=k){
return;
}
for(int i=0; i<n; i++){
// cout << boja[i];
if(boja[i]){
crna[i]=1;
}
else{
bijela[i]=1;
}
}
// cout << endl;
}
void rek(int x){
if(x==n){
probaj();
return;
}
boja[x]=1;
rek(x+1);
boja[x]=0;
rek(x+1);
}
string solve_puzzle(string s, vector < int > c){
n=s.size();
k=c.size();
v=c;
rek(0);
string sol;
for(int i=0; i<n; i++){
if(bijela[i] && crna[i]){
sol.push_back('?');
}
else if(bijela[i]){
sol.push_back('_');
}
else{
sol.push_back('X');
}
}
return sol;
}
# | 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... |