이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
vector<int> c;
bool canSolve(){
vector<vector<bool>> dp(n+1, vector<bool>(k+1, false));
dp[0][0] = true;
for(int i = 0; i < n; i++){
if(s[i] == 'X') break;
dp[i+1][0] = true;
}
int last_ = -1;
for(int i = 0; i < n; i++){
if(s[i] == '_') last_ = i;
for(int j = 0; j < k; j++){
int start = i+1-c[j];
if(start > last_){
if(start > 0) dp[i+1][j+1] = dp[start-1][j] && s[start-1] != 'X';
else if(j == 0) dp[i+1][j+1] = true;
}
if(s[i] != 'X') dp[i+1][j+1] = dp[i+1][j+1] || dp[i][j+1];
}
}
return dp[n][k];
}
string solve_puzzle(string S, vector<int> C){
s = S;
c = C;
n = (int)S.size();
k = (int)C.size();
string ans(n, ' ');
for(int i = 0; i < n; i++){
if(s[i] != '.') ans[i] = s[i];
else{
s[i] = '_';
bool w = canSolve();
s[i] = 'X';
bool b = canSolve();
s[i] = '.';
if(w && b) ans[i] = '?';
else ans[i] = w?'_':'X';
}
}
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... |