제출 #124007

#제출 시각아이디문제언어결과실행 시간메모리
124007tinjyuPaint By Numbers (IOI16_paint)C++14
90 / 100
1113 ms2696 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...