# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054626 | ArthuroWich | Paint By Numbers (IOI16_paint) | C++17 | 1 ms | 344 KiB |
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>
using namespace std;
string solve_puzzle(string s, vector<int> c) {
int n = s.length();
s = "@"+s;
vector<int> pref(n+1, 0);
for (int i = 1; i <= n; i++) {
pref[i] = pref[i-1];
if (s[i] == '_') {
pref[i]++;
}
}
vector<pair<int, int>> segs(c.size());
int i = 1, j = 0;
while(i <= n && j < c.size()) {
if (s[i] != '_' && pref[i+c[j]-1]-pref[i-1] == 0) {
segs[j].first = i-1;
i += c[j]+1;
j++;
} else {
i++;
}
}
i = n, j = c.size()-1;
while(i > 0 && j >= 0) {
if (s[i] != '_' && pref[i-c[j]+1]-pref[i-c[j]] == 0) {
segs[j].second = i-1;
i -= c[j]+1;
j--;
} else {
i--;
}
}
string ans(n, '?');
for (int i = 0; i < c.size(); i++) {
for (int j = segs[i].first; j <= segs[i].second; j++) {
ans[j] = '?';
}
if (segs[i].first+c[i]-1 >= segs[i].second-c[i]+1) {
for (int j = segs[i].second-c[i]+1; j <= segs[i].first+c[i]-1; j++) {
ans[j] = 'X';
}
}
}
for (int i = 0; i < n; i++) {
if (ans[i] == '?') {
ans[i] = '_';
}
}
return ans;
}
Compilation message (stderr)
# | 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... |