# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789646 | AkramElOmrani | Paint By Numbers (IOI16_paint) | C++17 | 1 ms | 308 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.
#pragma once
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
std::string solve_puzzle(std::string s, std::vector<int> c) {
int n = s.length();
int m = c.size();
string ans(n, '?');
int sm = accumulate(c.begin(), c.end(), 0) + c.size() - 1;
if(sm == n) {
int s = 0;
for(int i = 0; i < m; ++i) {
while(c[i]) {
c[i]--;
ans[s++] = 'X';
}
if(s != n)
ans[s++] = '_';
}
cout << ans << '\n';
return ans;
}
for(int i = 0; i < n; ++i) {
int before = 0;
int j = 0;
while(j < m && before + c[j] <= i) {
before += c[j++];
before++;
}
before = i + 1;
while(j < m && before + c[j] <= n) {
before += c[j++];
before++;
}
if(j != m) {
ans[i] = '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... |