Submission #321516

#TimeUsernameProblemLanguageResultExecution timeMemory
321516KuuhakuPaint By Numbers (IOI16_paint)C++17
100 / 100
391 ms103012 KiB
//Nov11-2020 #include <iostream> #include <stdio.h> #include <string> #include <vector> using namespace std; const int maxn=2e5+2; const int maxc=102; int n, k, type[maxc][maxn], demw[maxn], ch_b[maxn], ch_w[maxn]; string s; bool vs[maxc][maxn]; vector<int> c; void Enter() { k=c.size()-1; n=s.length(); s="."+s; for(int i=1;i<=n;i++) { demw[i]=demw[i-1]; if(s[i]=='_')demw[i]++; } int j=0; while(j<=n&&s[j]!='X') { type[0][j]=2; j++; } for(int i=1;i<=k;i++) for(int j=1;j<=n;j++) { bool add_b=(j>=c[i]&&type[i-1][j-c[i]]>1&&demw[j]==demw[j-c[i]]) ? 1 : 0; bool add_w=(type[i][j-1]>0&&s[j]!='X') ? 1 : 0; if(add_b&&!add_w)type[i][j]=1; if(!add_b&&add_w)type[i][j]=2; if(add_b&&add_w)type[i][j]=3; } } void Calc(int i,int j) { if(i<0||j<0)return; if(vs[i][j])return; vs[i][j]=true; if(type[i][j]==1||type[i][j]==3) { ch_b[j-c[i]+1]++; ch_b[j+1]--; ch_w[j-c[i]]++; Calc(i-1,j-c[i]-1); } if(type[i][j]==2||type[i][j]==3) { ch_w[j]++; Calc(i,j-1); } } string solve_puzzle(string t,vector<int> a) { s=t; c.push_back(0); for(int i:a)c.push_back(i); Enter(); Calc(k,n); int sum=0; string ans=""; for(int i=1;i<=n;i++) { sum+=ch_b[i]; if(sum>0&&ch_w[i]>0) ans+="?"; else { if(sum>0&&ch_w[i]==0) ans+="X"; else ans+="_"; } } return ans; }
#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...