이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <cstdlib>
#include <assert.h>
#include <iostream>
using namespace std;
int N,K;
int C[10005];
string DP[10005][105];
string S;
string F(int i, int j){
if(C[j]>=i+2 or i<0)
return "z";
if(DP[i][j]!="asd")
return DP[i][j];
for(int p=i;p>i-C[j];p--)
if(S[p]=='_'){
DP[i][j]="z";
return "z";
}
string s(i+1,'0');
if(j==0){
for(int p=i-C[j];p>=0;p--)
if(S[p]=='X'){
DP[i][j]="z";
return "z";
}
for(int p=0;p<=i-C[j];p++)
s[p]='_';
for(int p=i-C[j]+1;p<=i;p++)
s[p]='X';
DP[i][j]=s;
return s;
}
else{
bool flag=false;
for(int p=i-C[j];p>=0;p--){
if(S[p]=='X')
break;
if(F(p-1,j-1)!="z"){
if(!flag){
s=F(p-1,j-1);
for(int q=p;q<=i-C[j];q++)
s.push_back('_');
flag=true;
}
else{
string r;
r=F(p-1,j-1);
for(int q=p;q<=i-C[j];q++)
r.push_back('_');
assert(s.size()==r.size());
for(int q=0;q<=i-C[j];q++)
if(s[q]!=r[q])
s[q]='.';
}
}
}
if(!flag){
DP[i][j]="z";
return "z";
}
for(int p=i-C[j]+1;p<=i;p++)
s.push_back('X');
DP[i][j]=s;
return s;
}
}
string solve_puzzle(string s_, vector<int> c_) {
N=s_.size();
K=c_.size();
S=s_;
for(int i=0;i<N;i++)
C[i]=c_[i];
for(int i=0;i<N;i++)
for(int j=0;j<K;j++)
DP[i][j]="asd";
//for(int i=0;i<N;i++)for(int j=0;j<K;j++)cout<<i<<" "<<j<<" "<<F(i,j)<<"\n";
string A,B;
bool flag=false;
for(int i=0;i<N;i++)
if(F(i,K-1)!="z"){
B=(F(i,K-1));
bool g=true;
for(int p=B.size();p<N;p++)
if(S[p]=='X')
g=false;
if(!g)
continue;
while(B.size()<N)
B.push_back('_');
if(!flag){
A=B;
flag=true;
}
else
for(int i=0;i<N;i++)
if(A[i]!=B[i])
A[i]='.';
}
for(int i=0;i<N;i++)
if(A[i]=='.')
A[i]='?';
return A;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:128:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(B.size()<N)
~~~~~~~~^~
# | 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... |