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