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;
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a<< endl
#define nl "\n";
lli cont,mayor,sobrantes,n,a;
lli arr[1002];
string res;
std::string solve_puzzle(std::string s, std::vector<int> c) {
cont = 0;
for(auto act : c){
if (cont > 0) arr[cont++] = 0;
rep(i,1,act) arr[cont++] = i;
}
n = s.size();
sobrantes = n-cont;
res.resize(n);
if (sobrantes == 0){
rep(i,0,n-1) {
if (arr[i] == 0) res[i] = '_';
else res[i] = 'X';
}
return res;
}
mayor = 0;
repa(i,n-1,0) {
if(arr[i] > mayor) {
mayor = arr[i];
if (mayor < sobrantes){
a = sobrantes - mayor;
rep(j,1,a) {
res[i+j] = '?';
res[i+j+mayor] = '?';
}
}
}
else if (arr[i] == 0) {
mayor = 0;
continue;
}
if (arr[i] <= sobrantes) {
res[i] = '?';
res[i+mayor] = '?';
}
}
rep(i,0,n-1) if (res[i] != '?') res[i] = 'X';
return res;
}
# | 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... |