#include "paint.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC target("popcnt")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using lld = long double;
using ii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<ii>;
using vpll = vector<pll>;
using vlld = vector<lld>;
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define gcd(a,b) __gcd(a,b)
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fls cout.flush()
#define fore(i, l, r) for (auto i = l; i < r; i++)
#define fo(i, n) fore (i, 0, n)
#define forex(i, r, l) for (auto i = r-1; i >= l; i--)
#define ffo(i, n) forex (i, n, 0)
bool cmin(ll &a, ll b) { if (b < a) { a=b; return 1; } return 0; }
bool cmax(ll &a, ll b) { if (b > a) { a=b; return 1; } return 0; }
const ll INF = 1e18;
const int mod = 1e9 + 7, LOG = 20;
bool is_possible (ll n, ll k, string s, vector<int> c) {
vector<vll> dp(n+3, vll(k+3, 0));
s = 'w' + s;
{auto d = c;
c = vector<int>(1, 0);
fo (i, k) c.pb(d[i]);}
dp[0][0] = 1;
fore (i, 1, n+1) {
fo (j, k+1) {
// elegir nada
dp[i][j] |= (dp[i-1][j] && (s[i] != 'X' ? 1 : 0));
// elegir substring
if (c[j] <= i && j > 0) {
bool ok = 1;
forex (x, i+1, i-c[j]+1)
ok &= (s[x] != '_');
ok &= (s[i-c[j]] != 'X');
if (c[j] == i) dp[i][j] |= ((j == 1) && ok);
else dp[i][j] |= (dp[i-c[j]-1][j-1] && ok);
}
// ___XXX
}
}
return dp[n][k];
}
string solve_puzzle(string s, vector<int> c) {
ll n = s.size(), k = c.size();
string ans = s;
fo (i, n) {
if (s[i] != '.') continue;
s[i] = 'X';
if (is_possible(n, k, s, c)) ans[i] = 'X';
s[i] = '_';
if (is_possible(n, k, s, c)) ans[i] = (ans[i] == 'X' ? '?' : '_');
s[i] = '.';
}
return ans;
}
컴파일 시 표준 에러 (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... |