# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410722 | DBPhoenix | Paint By Numbers (IOI16_paint) | C++17 | 1 ms | 304 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) {
string out;
int n = s.size();
out = s;
long long min = 0;
long long max = c[0];
for (int i = 1; i < c.size(); i++) max += c[i] + 1;
for (int k = 0; k < c.size(); k++)
{
int i = min;
if (k == c.size() - 1)
for (int j = min + c[k]; j < n; j++)
out[j] = (out[j] == 'X' || out[j] == '?') ? '?' : '_';
for (; i <= n - max; i++)
{
bool skip = false;
for (int j = 0; j < c[k]; j++)
if (s[i + j] == '_') skip = true;
if (skip) continue;
if (i > 0)
if (s[i - 1] == '.')
out[i - 1] = (out[i - 1] == 'X' || out[i - 1] == '?') ? '?' : '_';
for (int j = 0; j < c[k]; j++)
out[i + j] = (out[i + j] == '_' || out[i + j] == '?') ? '?' : 'X';
if (i + c[k] < n)
if (s[i + c[k]] == '.')
out[i + c[k]] = (out[i + c[k]] == 'X' || out[i + c[k]] == '?') ? '?' : '_';
}
if (k == 0)
for (int j = 0; j < i - 1; j++)
out[j] = (out[j] == 'X' || out[j] == '?') ? '?' : '_';
max -= c[k] + 1;
min += c[k] + 1;
}
return out;
}
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... |