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(string s, vector<int> c, vector<int> &bid) {
int lst = 0;
for (int k = 0; k < (int)c.size(); k++) {
bool flag;
int x = c[k];
do {
flag = true;
for (int i = lst; i < lst + x; i++) {
// cerr << i << " " << endl;
flag &= (s[i] == '.');
}
if (flag) {
for (int i = lst; i < lst + x; i++) {
s[i] = 'X';
bid[i] = k;
}
lst += x;
} else {
lst++;
}
} while (!flag);
lst++;
}
return s;
}
std::string solve_puzzle(std::string s, std::vector<int> c) {
int n = s.size();
string a, b;
vector<int> aa, bb;
aa = bb = vector<int>(n, -1);
reverse(s.begin(), s.end());
reverse(c.begin(), c.end());
a = solve(s, c, aa);
reverse(a.begin(), a.end());
reverse(aa.begin(), aa.end());
for (int &i : aa) {
i = c.size() - i - 1;
}
reverse(s.begin(), s.end());
reverse(c.begin(), c.end());
b = solve(s, c, bb);
cerr << a << endl;
cerr << b << endl;
for (int i = 0; i < (int)n; i++) {
if (a[i] == 'X' && b[i] == 'X' && aa[i] == bb[i]) {
s[i] = 'X';
} else if (a[i] == 'X' || b[i] == 'X') {
s[i] = '?';
} else if (s[i] == '.') {
int u, v;
u = v = i;
while (u >= 0 && aa[u] == -1)
u--;
while (v < n && bb[v] == -1)
v++;
if (u == -1 || v == n || (aa[u] == bb[v])) {
s[i] = '?';
}
}
}
return s;
}
# | 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... |