#include <bits/stdc++.h>
// mrrrow meeow :3
// go play vivid/stasis now! https://vividstasis.gay
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = [] {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
return 0;
}();
int n;
vector<int> c;
int empties[200001];
bool check_empty(int l, int r) {
return empties[min(r, n)] - empties[l];
}
int filled[200001];
bool check_filled(int l, int r) {
return filled[min(r, n)] - filled[l];
}
int checked[101];
string res;
bool check(int i, int j) {
if (i >= c.size()) return true;
checked[i] = j;
cerr << i << ' ' << j << endl;
if (check_empty(j, j + c[i])) return false;
of(k, j + c[i] + 1, checked[i + 1]) {
if (!check_filled(j + c[i], k) && check(i + 1, k)) {
fo(l, j, j + c[i]) res[l] = 'X';
return true;
}
}
return false;
}
string solve_puzzle(string s, vector<int> _c) {
n = s.size();
res.resize(n, '_');
c = _c;
fo(i, 0, c.size()) checked[i] = n - c[i] + 1;
checked[c.size()] = n + 2;
fo(i, 0, n) {
empties[i + 1] = empties[i] + (s[i] == '_');
filled[i + 1] = filled[i] + (s[i] == 'X');
}
of(i, 0, checked[0]) if (!check_filled(0, i) && check(0, i)) return res;
}
Compilation message (stderr)
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]
73 | }
| ^
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... |