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 <bits/stdc++.h>
using namespace std;
string solve_puzzle(string s, vector<int> c) {
int n = s.size(), k = c.size();
vector<bool> white(n, true), black(n, true);
for(int mask = 0; mask < (1 << n); mask++) {
vector<bool> puzzle(n);
for(int i = 0; i < n; i++) puzzle[i] = (mask >> i & 1);
int ptr = 0;
bool flag = 1;
for(int i = 0, j = 0; i < n && j < n && ptr < k; i = j) {
while(j < n && puzzle[i] == puzzle[j]) j++;
if(puzzle[i] == 1) {
int cnt = j - i;
if(cnt == c[ptr]) ptr++;
else {
flag = 0; break;
}
}
}
if(ptr != k) continue;
if(!flag) continue;
for(int i = 0; i < n; i++) {
white[i] = white[i] && (puzzle[i] == 0);
black[i] = black[i] && (puzzle[i]);
}
}
string ans = "";
for(int i = 0; i < n; i++) {
if(black[i]) ans += "X";
else if(white[i]) ans += "_";
else ans += "?";
}
return ans;
}
# | 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... |