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 <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int n, k;
int pref[maxn];
int sum(int l, int r){
if(l > r) return 0;
return pref[r] - pref[l-1];
}
string solve_puzzle(std::string s, std::vector<int> c){
n = s.size();
s = "#" + s; k = c.size();
reverse(c.begin(), c.end());
c.push_back(0);
reverse(c.begin(), c.end());
for(int i = 1; i <= k; i++){
pref[i] += pref[i-1] + c[i];
}
string res;
vector<int> ans = {'.', 'Y', 'X', '?'};
for(int i = 1; i <= n; i++){
int x = 0;
for(int j = 1; j <= k; j++){
int l = sum(1, j - 1) + j;
int r = n - sum(j + 1, k) - k + j;
if(l <= i && i <= r && r - l + 1 >= c[j]) x |= 2;
}
for(int j = 0; j <= k; j++){
int l = sum(1, j) + max(j, 1);
int r = 1 + n - sum(j + 1, k) - max(1, k - j);
if(l <= i && i <= r) x |= 1;
}
res.push_back(ans[x]);
}
return res;
}
# | 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... |