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>
#include <cstdlib>
using namespace std;
const int MAXN = 110;
string resp;
pair <int, int> v[MAXN];
string solve_puzzle(string s, vector<int> c) {
resp.resize(s.size());
int n = s.size();
int k = c.size();
int at = 0;
for(int i = 0; i < n; i++) {
bool ok = true;
if(at == k) break;
for(int j = 0; j < c[at]; j++) {
if(s[j + i] == '_') ok = false;
}
if(ok) {
v[at].first = i;
i = i + c[at] ;
at++;
}
}
at = k - 1;
for(int i = n - 1; i >= 0; i--) {
bool ok = true;
if(at == -1) break;
for(int j = 0; j < c[at]; j++) {
if(s[i - j] == '_') ok = false;
}
if(ok) {
v[at].second = i;
i = i - c[at];
at--;
}
}
//printf("%d %d\n", v[0].first, v[0].second);
for(int i = 0; i < n; i++) resp[i] = '?';
for(int i = 0; i < k; i++) {
//printf("%d %d\n", v[i].first, v[i].second);
for(int j = v[i].second - c[i] + 1; j <= v[i].first + c[i] - 1; j++) resp[j] = 'X';
/*for(int j = v[i].first; j < v[i].first + c[i]; j++) if(resp[j] != 'X') resp[j] = '?';
for(int j = v[i].second - c[i] + 1; j <= v[i].second; j++) if(resp[j] != 'X') resp[j] = '?';*/
}
for(int i = 0; i < k - 1; i++) {
for(int j = v[i].second + 1; j < v[i + 1].first; j++) resp[j] = '_';
}
for(int i = 0; i < n; i++) if(s[i] == '_') resp[i] = '_';
return resp;
}
# | 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... |