제출 #287061

#제출 시각아이디문제언어결과실행 시간메모리
287061SamAndPaint By Numbers (IOI16_paint)C++17
80 / 100
4 ms512 KiB
#include "paint.h" #include <cstdlib> #include <bits/stdc++.h> using namespace std; #define m_p make_pair #define fi first #define se second #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() const int N = 103; int n; string s; int k; vector<int> c; int p[N]; bool dp[N][N][2]; bool stg() { memset(dp, false, sizeof dp); dp[0][0][0] = true; for (int i = 1; i <= n; ++i) { p[i] = p[i - 1]; if (s[i] == '_') p[i]++; } for (int i = 0; i < n; ++i) { for (int j = 0; j <= k; ++j) { for (int z = 0; z < 2; ++z) { if (!dp[i][j][z]) continue; if (s[i + 1] != 'X') dp[i + 1][j][0] = true; if (!z) { if (j != k) { if (i + c[j + 1] <= n) { if (p[i + c[j + 1]] - p[i] == 0) { dp[i + c[j + 1]][j + 1][1] = true; } } } } } } } return (dp[n][k][0] || dp[n][k][1]); } std::string solve_puzzle(std::string s_, std::vector<int> c_) { n = sz(s_); s = s_; k = sz(c_); c = c_; reverse(all(s)); s += '@'; reverse(all(s)); reverse(all(c)); c.push_back(0); reverse(all(c)); string ans; for (int i = 1; i <= n; ++i) { if (s[i] != '.') ans.push_back(s[i]); else { s[i] = '_'; bool z1 = stg(); s[i] = 'X'; bool z2 = stg(); s[i] = '.'; if (z1 && z2) ans.push_back('?'); else { if (z1) ans.push_back('_'); else ans.push_back('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...