#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple <ll,ll,ll> plll;
typedef vector <plll> vplll;
typedef pair <ll,ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <vector <pll>> vvpll;
typedef vector <vector <ll>> vvll;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e9 + 7;
string solve_puzzle(string s, vector<int> c) {
int n = s.size(), k = c.size();
vector<int> l(k), r(k);
int pos = 0;
for (int i = 0; i < k; ++i) {
while (pos + c[i] <= n) {
bool ok = true;
for (int t = pos; t < pos + c[i]; ++t)
if (s[t] == '_') { ok = false; break; }
if (ok) break;
++pos;
}
l[i] = pos;
pos += c[i] + 1;
}
pos = n;
for (int i = k - 1; i >= 0; --i) {
int start = pos - c[i];
while (start >= 0) {
bool ok = true;
for (int t = start; t < start + c[i]; ++t)
if (s[t] == '_') { ok = false; break; }
if (ok) break;
--start;
}
r[i] = start;
pos = start - 1;
}
string ans(n, '?');
for (int i = 0; i < k; ++i) {
int a = max(l[i], r[i]);
int b = min(l[i] + c[i] - 1, r[i] + c[i] - 1);
for (int x = a; x <= b; ++x)
ans[x] = 'X';
}
for (int x = 0; x < n; ++x) {
bool cover = false;
for (int i = 0; i < k; ++i)
if (x >= l[i] && x <= r[i] + c[i] - 1) { cover = true; break; }
if (!cover) ans[x] = '_';
}
return ans;
}
Compilation message (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... |