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 "paint.h"
#include <bits/stdc++.h>
using namespace std;
const int N=2e2+10;
int dp[N][N];
string ss;
vector<int> cc;
int n,k,m;
string tr;
int okx(int u)
{
dp[0][0]=1;
bool f=1;
for(int i=1;i<=n;i++){
if(f&&ss[i-1]!='X'){
dp[i][0]=1;
}
else{
f=0;
}
for(int j=1;j<=m;j++){
dp[i][j]=0;
if((ss[i-1]!='X'&&(tr[j-1]!='X'||j==m))){
dp[i][j]|=dp[i-1][j];
}
if(ss[i-1]!='_'&&tr[j-1]=='X'){
dp[i][j]|=dp[i-1][j-1];
}
if(ss[i-1]!='X'&&tr[j-1]=='_'){
dp[i][j]|=dp[i-1][j-1];
}
}
}
return dp[n][m];
}
string solve_puzzle(string s,vector<int> c){
string ans=s;
cc=c;
ss=s;
n=s.size();
k=c.size();
for(int i=0;i<k;i++){
for(int j=0;j<c[i];j++){
tr+='X';
}
tr+='_';
}
tr.pop_back();
m=tr.size();
for(int i=0;i<n;i++){
if(s[i]!='.')continue;
int ok=0;
ss[i]='X';
ok+=okx(i);
ss[i]='_';
ok+=2*okx(i);
ss[i]='.';
if(ok==1)ans[i]='X';
if(ok==2)ans[i]='_';
if(ok==3)ans[i]='?';
}
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... |