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 <bits/stdc++.h>
#include "paint.h"
using namespace std;
#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
std::string solve_puzzle(std::string st, std::vector<int> c) {
int n= st.size();
int k = c.size();
vi vec(n);
frange(i, n) {
if(st[i] == 'X') vec[i] = 1;
else if(st[i] == '.') vec[i] = -1;
}
string out = "";
frange(i, n) {
if(vec[i] != -1) {
if(vec[i]) out += 'X';
else out += '_';
}
vector<vvi> dp(n, vvi(k+1, vi(n+1)));
vec[i] = 1;
forr(j, 0, n)
dp[j][0][0] = true;
dp[0][1][1] = true;
forr(j, 1, n) {
forr(l, 1, k+1) {
if(vec[j] == 0 || vec[j] == -1)
dp[j][l][0] = dp[j-1][l][0] || dp[j-1][l][vec[j]];
if(vec[j] == 1 || vec[j] == -1) {
dp[j][l][1] = dp[j - 1][l - 1][0];
forr(e, 2, c[l-1] + 1) {
dp[j][l][e] = dp[j - 1][l][e - 1];
}
}
}
}
bool black = dp[n-1][k][c[k-1]] || dp[n-1][k][0];
dp = vector<vvi>(n, vvi(k+1, vi(n+1)));
vec[i] = 0;
forr(j, 0, n)
dp[j][0][0] = true;
dp[0][1][1] = true;
forr(j, 1, n) {
forr(l, 1, k+1) {
if(vec[j] == 0 || vec[j] == -1)
dp[j][l][0] = dp[j-1][l][0] || dp[j-1][l][vec[j]];
if(vec[j] == 1 || vec[j] == -1) {
dp[j][l][1] = dp[j - 1][l - 1][0];
forr(e, 2, c[l-1] + 1) {
dp[j][l][e] = dp[j - 1][l][e - 1];
}
}
}
}
bool white = dp[n-1][k][c[k-1]] || dp[n-1][k][0];
if(black && white) {
out += '?';
}
else if(black) out += 'B';
else out += 'W';
}
return out;
}
# | 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... |