제출 #200989

#제출 시각아이디문제언어결과실행 시간메모리
200989AQTPaint By Numbers (IOI16_paint)C++14
0 / 100
5 ms376 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; long long pre[2][200005]; bool dp[2][105][200005]; int par[2][105][200005]; string solve_puzzle(string s, vector<int> c){ int N = s.size(), K = c.size(); for(int i = 1; i<=N; i++){ if(s[i-1] == '_'){ pre[0][i] = 1; } else if(s[i-1] == 'X'){ pre[1][i] = 1; } pre[0][i] += pre[0][i-1]; pre[1][i] += pre[1][i-1]; } dp[0][0][0] = 1; for(int k = 0; k<=K; k++){ for(int i= 0; i<=N; i++){ for(int b = 0; b<2; b++){ if(dp[b][k][i]){ if(s[i] != 'X'){ par[0][k][i+1] = -b; dp[0][k][i+1] = 1; } if(k != K && c[k] + i <= N && pre[0][c[k]+i]-pre[0][i] == 0){ par[1][k+1][i+c[k]] = 1; dp[1][k+1][i+c[k]] = 1; } } } } } string ret; int crntb = 0, crntk = K, crntn = N; if(dp[1][K][N]){ crntb = 1; } while(crntn){ if(par[crntb][crntk][crntn] == 1){ int lim = crntn - c[crntk-1]; while(crntn > lim){ ret.push_back('X'); crntn--; } crntk--; crntb ^= 1; } else if(par[crntb][crntk][crntn] == -1){ crntb ^= 1; crntn--; ret.push_back('_'); } else{ ret.push_back('_'); crntn--; } } reverse(ret.begin(), ret.end()); return ret; } /* int main(){ cout << solve_puzzle("..........", {3, 4}) << endl; } */
#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...