제출 #291683

#제출 시각아이디문제언어결과실행 시간메모리
291683peti1234Paint By Numbers (IOI16_paint)C++17
100 / 100
480 ms43160 KiB
#include <bits/stdc++.h> using namespace std; const int c=200002, p=102; int n, k, kom[c], dp[c]; string ans; bool kezd[c][p], veg[c][p], v[c]; string solve_puzzle(string s, vector<int> sz) { n=s.size(), k=sz.size(); s+='.'; for (int i=0; i<n; i++) kom[i+1]=(s[i]=='_')+kom[i]; kezd[0][0]=1; for (int i=0; i<n; i++) for (int j=0; j<=k; j++) if (kezd[i][j]) { if (s[i]!='X') kezd[i+1][j]=1; if (j<k) { int h=sz[j]; if (i+h<=n && kom[i+h]==kom[i] && s[i+h]!='X') kezd[i+h+1][j+1]=1; } } veg[n][k]=1; for (int i=n; i>=1; i--) for (int j=k; j>=0; j--) if (veg[i][j]) { if (s[i-1]!='X') veg[i-1][j]=1; if (j) { int h=sz[j-1]; if (i-h-1>=0 && kom[i]==kom[i-h] && s[i-h-1]!='X') veg[i-h-1][j-1]=1; } } for (int i=n; i>=0; i--) for (int j=k; j>=0; j--) if (veg[i][j]) veg[i+1][j]=1; for (int i=1; i<=n; i++) for (int j=0; j<=k; j++) { if (kezd[i][j] && veg[i][j]) v[i]=1; if (j<k) { int h=sz[j]; if (i+h<=n+1 && kom[i-1]==kom[i+h-1] && s[i+h-1]!='X' && kezd[i-1][j] && veg[i+h][j+1]) dp[i]++, dp[i+h]--; } } for (int i=1; i<=n; i++) { dp[i]+=dp[i-1]; if (v[i] && dp[i]) ans+='?'; if (v[i] && !dp[i]) ans+='_'; if (!v[i] && dp[i]) ans+='X'; } 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...