This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "paint.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;
template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 200010;
int n, m;
int arr[MAXN], lo[MAXN], hi[MAXN]; // left endpoint
string solve_puzzle(std::string s, std::vector<int> c) {
n = s.size();
m = c.size();
for (int i = 1; i <= m; ++i) arr[i] = c[i-1];
for (int i = 1; i <= m; ++i) {
lo[i] = lo[i-1] + arr[i-1] + 1;
}
hi[m+1] = n+2;
for (int i = m; i >= 1; --i) {
hi[i] = hi[i+1] - 1 - arr[i];
}
vector<pi> black, white;
for (int i = 1; i <= m; ++i) {
if (lo[i] == hi[i]) {
black.pb({lo[i], lo[i]+arr[i]-1});
white.pb({lo[i]+arr[i], lo[i]+arr[i]});
} else {
if (hi[i] <= lo[i] + arr[i] -1) {
black.pb({hi[i], lo[i] + arr[i] - 1});
}
}
}
string ans = "";
for (int i = 1; i <= n; ++i) ans += '?';
for (auto [l,r]: black) {
for (int idx = l; idx <= r; ++ idx) if (idx <= n) ans[idx-1] = 'X';
}
for (auto [l,r]: white) {
for (int idx = l; idx <= r; ++ idx) if (idx <= n) ans[idx-1] = '_';
}
return ans;
}
# | 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... |