제출 #1021800

#제출 시각아이디문제언어결과실행 시간메모리
1021800vjudge1Paint By Numbers (IOI16_paint)C++17
59 / 100
1 ms8796 KiB
#include <bits/stdc++.h> #define ent '\n' typedef long long ll; using namespace std; const int maxn = 2e5+12; int suff[maxn][103]; int pref[maxn][103]; int r[maxn][103]; int prefw[maxn]; int prefb[maxn]; int c[maxn]; int n, k; string solve_puzzle(string s, vector<int> C){ n = s.size(), k = C.size(); for(int i=0;i<n;i++){ prefw[i+1] = prefw[i] + (s[i] == '_'); prefb[i+1] = prefb[i] + (s[i] == 'X'); c[i+1] = C[i]; } string ans = ""; pref[0][0] = 1; for(int i=1;i<=n;i++){ for(int j=0;j<=k;j++){ if(s[i-1] != 'X') pref[i][j] = pref[i-1][j]; if(j > 0 && i > c[j] && pref[i-c[j]-1][j-1] && prefw[i] == prefw[i-c[j]]) { pref[i][j] = 1; } if(j == 1 && i >= c[j] && pref[i-c[j]][j-1] && prefw[i] == prefw[i-c[j]]){ pref[i][j] = 1; } } } suff[n+1][k+1] = 1; for(int i=n;i;i--){ for(int j=k+1;j>0;j--){ if(s[i-1] != 'X') suff[i][j] = suff[i+1][j]; if(j <= k && n - i + 1 > c[j] && suff[i+c[j]+1][j+1] && prefw[i+c[j]-1] == prefw[i-1]){ suff[i][j] = 1; } if(j == k && n - i + 1 >= c[j] && suff[i+c[j]][j+1] && prefw[i+c[j]-1] == prefw[i-1]){ suff[i][j] = 1; } } } for(int j=1;j<=k;j++){ r[0][j] = -1e9; } for(int i=1;i<=n;i++){ bool ok = 0, fg = 0; for(int j=0;j<=k;j++){ if(pref[i-1][j] && suff[i+1][j+1] && s[i-1] != 'X'){ fg = 1; } } for(int j=1;j<=k;j++){ r[i][j] = r[i-1][j]; if(i - 1 - (j != 1) >= 0 && i+c[j] + (j != k) <= n+1 && pref[i - 1 - (j != 1)][j-1] && suff[i+c[j] + (j != k)][j+1] && prefw[i+c[j]-1] == prefw[i-1]){ r[i][j] = i; } if(r[i][j] + c[j] - 1 >= i){ ok = 1; } } if(!fg){ ans += 'X'; } else if(!ok){ ans += '_'; } 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...