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"
#include "paint.h"
using namespace std;
using ll = long long;
using pi = pair<long long, long long>;
using vi = vector<long long>;
#define pb emplace_back
string solve_puzzle(string s, vector<int> c) {
ll k = c.size();
ll n = s.size();
vector<vi> sets;
string res(n, '?');
for(int i = 0; i < (1<<n); ++i) {
vi subset;
for(int j = 0; j < n; ++j) {
if(i & (1<<j))
subset.pb(1);
else
subset.pb(0);
}
vi len;
ll curr = 0;
for(int j = 0; j < n; ++j) {
if(subset[j] == 0) {
if(curr != 0)
len.pb(curr);
curr = 0;
} else {
++curr;
}
}
if(curr != 0) len.pb(curr);
if((int) len.size() != k) continue;
bool valid = true;
for(int j = 0; j < k; ++j) {
if(len[j] != c[j]) {
valid = false;
break;
}
}
if(valid)
sets.pb(subset);
}
for(int i = 0; i < n; ++i) {
int fr = sets[0][i];
bool confuse = false;
for(int j = 1; j < (int) sets.size(); ++j) {
if(sets[j][i] != fr) {
confuse = true;
break;
}
}
if(!confuse)
res[i] = (fr ? 'X' : '_');
}
return res;
}
# | 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... |