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;
using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;
#define all(v) v.begin(),v.end()
#define sort(v) sort(all(v))
#define endl '\n'
#define forn(i,n) for(int i = 0; i < n; ++i)
#define forbe(i,b,e) for(int i = b; i < e; ++i)
#define forr(i,n) for(int i = n-1; i >= 0; --i)
#define sz(v) ((int)v.size())
#define pb push_back
#define f first
#define s second
string solve_puzzle(string s, vi c) {
string ans = s;
forn(i,sz(s))
ans[i] = '?';
int k = sz(c);
int ps = 0;
forn(i,k) {
ps += c[i];
}
ps += k;
int d = 0;
int n = sz(s);
forn(i,k) {
ps -= c[i];
ps -= 1;
if (n - d - c[i] - ps == 0) {
if (ps)
ans[n-ps] = '_';
}
forbe(j,n-ps-c[i],d + c[i])
ans[j] = 'X';
d += c[i];
++d;
}
return ans;
}
#ifdef ONPC
void solve() {
int n, k;
cin >> k;
string s;
cin >> s;
vi c(k);
forn(i,k)
cin >> c[i];
string ans = solve_puzzle(s,c);
cout << ans << endl;
}
int main() {
freopen("in", "r", stdin);
// ios_base::sync_with_stdio(0);cin.tie(0);
solve();
}
#endif
# | 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... |