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 <bits/stdc++.h>
using namespace std;
std::string solve_puzzle(std::string s, std::vector<int> c) {
int n = s.size(), k = c.size();
vector<int> ans(n);
int sum = accumulate(c.begin(), c.end(), 0);
if(sum + k - 1 == n){
string res;
for(int i = 0; i < k; i++){
if(i) res += '_';
res += string(c[i], 'X');
}
return res;
}else{
string ans = string(n, 'X');
for(int i = 0; i < n; i++){
int has = 0;
int gd = 1;
int pre = 0;
for(int j = 0; j < k; j++){
if(has + c[j] + (j != 0) <= i) has += c[j] + (j != 0), pre += c[j];
else{
if(i + sum - pre + (k - j) - 1 >= n) gd = 0;
}
}
if(gd) ans[i] = '?';
}
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... |