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>
#include <cstdlib>
using namespace std;
bool isEmpty(string s) {
for (char x: s)
if (x != '.') return false;
return true;
}
std::string solve_puzzle(std::string s, std::vector<int> c) {
string ans;
int n = s.size(), k = c.size();
for (int i=0; i<n; i++) ans += '?';
if (k == 1) {
k = c[0];
for (int i=0; i<2*k-n; i++) ans[i+n-k] = 'X';
return ans;
} else if (isEmpty(s)) {
int totalSpace = k-1;
for (int x: c) totalSpace += x;
int gap = n - totalSpace, pt = 0;
for (int i=0; i<k; i++) {
// solve(start: pt, end: pt + gap + c_i (exclusive))
int tempN = gap + c[i];
for (int j=0; j<2*c[i]-tempN; j++) {
ans[pt + j + tempN - c[i]] = 'X';
}
pt += c[i] + 1; // size + gap
}
}
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... |