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;
using ll = long long;
/*
....
2
9 3
*/
std::string solve_puzzle(std::string str, std::vector<int> c) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// str = string(20, '.');
int n = str.length(), k = c.size();
string orig;
for(int i = 0; i < k; i++) {
for(int j = 0; j < c[i]; j++) {
orig += 'X';
}
if (i != k-1) {
orig += '_';
}
}
vector<int> pref(k+1, 0);
for(int i = 1; i <= k; i++) {
pref[i] += pref[i-1];
pref[i] += c[i-1];
// cout << pref[i] << "\n";
}
string ans;
for(int i = 0; i < n; i++) {
bool ok = false;
for(int j = 0; j <= k; j++) {
// cout << i << " " << j << " " << pref[j]+(j-1) << " " << (pref[k] - pref[j]) + (k-j) << "\n";
int diff = (i - (pref[j]+(j-1))) + (n-i-1) - ((pref[k]-pref[j])+(k-j-1));
if (i >= pref[j]+(j-1) && (n-i-1) >= (pref[k] - pref[j]) + (k-j-1) && diff > 0) {
ans += '?';
ok = true;
break;
}
}
if (!ok) {
ans += orig[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... |