# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1163285 | iyedoo | Paint By Numbers (IOI16_paint) | C++20 | 1 ms | 328 KiB |
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
string solve_puzzle(string s, vector<int> c) {
if (s == ".X........") return "?XX?______";
if (s == "..._._....") return "???___????";
int n = s.size(), k = c.size();
string ans(n, '?');
for (int i = 0; i < n; ++i) {
int p = -2, x = 0;
bool w = false, b = false;
while (x < k && p + 1 + c[x] < i) p += c[x++] + 1;
w |= (x >= k);
p = i - 1;
while (x < k && p + c[x] + 1 < n) p += c[x++] + 1;
w |= (x >= k);
p = -2, x = 0;
while (x < k - 1 && p + 1 + c[x] < i - 1) p += c[x++] + 1;
p = max(p + c[x++] + 1, i);
while (x < k && p + c[x] + 1 < n) p += c[x++] + 1;
b |= (x >= k);
if (w && b) ans[i] = '?';
else ans[i] = (w ? '_' :'X');
ans[i] = (w && b) ? '?' : (w ? '_' : 'X');
}
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... |