#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
bool pos(string s, vector<int> c) {
int n = s.size();
int k = c.size();
vector<vector<bool>> dp(n+2, vector<bool>(k+1, false));
vector<int> ps(n, 0);
if (s[0] == '_') ps[0] = 1;
for (int i = 1; i < n; i++) {
ps[i] = ps[i-1];
if (s[i] == '_') ps[i]++;
}
for (int i = 0; i <= n+1; i++) dp[i][k] = true;
for (int curr = k-1; curr >= 0; curr--) {
for (int i = n-1; i >= 0; i--) {
dp[i][curr] = dp[i+1][curr];
if (dp[i][curr]) continue;
int upto = i + c[curr] - 1;
if (upto >= n) continue;
if (upto < n-1 && s[upto+1] == 'X') continue;
int tot = ps[upto];
if (i > 0) tot -= ps[i-1];
if (tot != 0) continue;
dp[i][curr] = dp[upto + 2][curr+1];
}
}
return dp[0][0];
}
std::string solve_puzzle(std::string s, std::vector<int> c) {
int n = s.size();
int k = c.size();
string ans = s;
for (int i = 0; i < n; i++) {
if (s[i] != '.') continue;
bool posX = false, pos_ = false;
s[i] = 'X';
if (pos(s, c)) posX = true;
s[i] = '_';
if (pos(s, c)) pos_ = true;
if (posX && pos_) ans[i] = '?';
else if (posX) ans[i] = 'X';
else ans[i] = '_';
s[i] = '.';
}
return ans;
}
/*
int main() {
string s; cin >> s;
int k; cin >> k;
vector<int> c(k);
for (int i = 0; i < k; i++) cin >> c[i];
cout << solve_puzzle(s, c) << "\n";
}*/
컴파일 시 표준 에러 (stderr) 메시지
paint.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
paint_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |