이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <cstdlib>
#include <iostream>
using namespace std;
long long int m,n,c[5005],tag[105][5005],ans[5005];
string s;
string a;
long long int find(int p,int now)
{
if(tag[p][now]!=0)return tag[p][now];
if(p==m)
{
for(int i=now;i<n;i++)
{
if(s[i]=='X')return 2;
}
return 1;
}
tag[p][now]=2;
long long int max=-1;
for(int i=now;i+c[p]-1<n;i++)
{
if(i>max && max!=-1)break;
long long int cnt=0;
if(s[i]=='X' && max==-1)max=i;
for(int j=0;j<c[p];j++)
{
if(s[j+i]=='_')
{
cnt=1;
break;
}
}
if(cnt==1 || s[c[p]+i]=='X')continue;
if(find(p+1,i+c[p]+1)==1)
{
//cout<<p<<" "<<now<<" "<<i<<endl;
//cout<<a<<endl;
for(int j=now;j<i;j++)
{
if(a[j]=='.')a[j]='_';
if(a[j]=='X')a[j]='?';
}
//cout<<a<<endl;
for(int j=i;j<i+c[p];j++)
{
if(a[j]=='.')a[j]='X';
if(a[j]=='_')a[j]='?';
}
//cout<<a<<endl;
if(p!=m-1)
{
if(a[i+c[p]]=='.')a[i+c[p]]='_';
if(a[i+c[p]]=='X')a[i+c[p]]='?';
}
else
{
for(int j=i+c[p];j<n;j++)
{
if(a[j]=='.')a[j]='_';
if(a[j]=='X')a[j]='?';
}
}
tag[p][now]=1;
//cout<<a<<endl;
}
}
return tag[p][now];
}
std::string solve_puzzle(std::string x, std::vector<int> l) {
s=x;
a=x;
m=l.size();
n=s.length();
for(int i=0;i<n;i++)a[i]=s[i];
for(int i=0;i<m;i++)c[i]=l[i];
find(0,0);
//cout<<a<<endl;
return a;
}
# | 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... |