이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "paint.h"
using namespace std;
const int maxn = 102;
bool dp[maxn][maxn][maxn]; // dp[i][j][k] -> is it possible to form an answer considering first i characters, first j blocks, and i being the k-th X of the j-th block
string solve_puzzle(string s, vector<int> c) {
int n = s.size();
int k = c.size();
s.push_back('_');
c.push_back(0);
auto check = [&] () {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int i = 1; i <= n + 1; i++){
for (int j = 0; j <= k; j++){
for (int ps = 0; ps <= c[j]; ps++){
char now = s[i-1];
if ((now == 'X' || now == '.') && ps) {
dp[i][j][ps] |= dp[i-1][j][ps - 1];
}
if ((now == '_' || now == '.') && !ps) {
if (j) dp[i][j][0]|=dp[i-1][j-1][c[j-1]];
dp[i][j][0]|=dp[i-1][j][0];
}
// if (dp[i][j][ps]) cout << i << " " << j << " " << ps << "\n";
}
}
}
return dp[n + 1][k][0];
};
string rs(n, '.');
for (int i = 0; i < n; i++){
if (s[i] != '.') rs[i]=s[i];
else {
s[i] = 'X';
bool p1 = check();
s[i] = '_';
bool p2 = check();
// cout << i << " " << p1 << " " << p2 << "\n";
if (p1 && p2) rs[i]='?';
else if (p1) rs[i]='X';
else if (p2) rs[i]='_';
s[i] = '.';
}
}
return rs;
}
# | 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... |