이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "paint.h"
using namespace std;
int n, k;
int W[101], B[101];
bool white[101], black[101];
string cur;
void solve(int r, int i, string &s, vector<int> &c, int suff_sum)
{
if (i == k)
{
for (int j = 1; j <= n; j++)
if (cur[j] == 'X')
black[j] = true;
else if (cur[j] == '_')
white[j] = true;
return;
}
for (int j = r + 2; j + suff_sum - 1 <= n; j++)
if (W[j + c[i] - 1] - W[j - 1] == 0 && (B[j - 1] - B[r] == 0 || (r == -1 && B[j-1] == 0)))
{
for (int m = j; m <= j + c[i] - 1; m++)
cur[m] = 'X';
solve(j + c[i] - 1, i + 1, s, c, suff_sum - c[i]);
for (int m = j; m <= j + c[i] - 1; m++)
cur[m] = '_';
}
}
string solve_puzzle(string s, vector<int> c)
{
n = s.size(), k = c.size();
s = "#" + s;
W[0] = B[0] = 0;
for (int i = 1; i <= n; i++)
{
W[i] = W[i-1] + (s[i] == '_');
B[i] = B[i-1] + (s[i] == 'X');
}
memset(white, false, sizeof(white));
memset(black, false, sizeof(black));
cur = "#" + string(n, '_');
int sum = 0;
for (int i = 0; i < k; i++)
sum += c[i];
solve(-1, 0, s, c, sum);
string res = "";
for (int i = 1; i <= n; i++)
{
if (white[i] && black[i])
res += "?";
else if (white[i])
res += "_";
else if (black[i])
res += "X";
else
res += "F";
}
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... |