# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966924 | MarwenElarbi | Paint By Numbers (IOI16_paint) | C++17 | 0 ms | 0 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.
#include <bits/stdc++.h>
//#include "paint.h"
using namespace std;
const int S_MAX_LEN = 200 * 1000;
char buf[S_MAX_LEN + 1];
string solve_puzzle(std::string s, std::vector<int> c) {
int n=s.size();
int m=c.size();
int beg[m];
int a=0;
for (int i = 0; i < n; ++i)
{
s[i]='?';
}
for (int i = 0; i < m; ++i)
{
beg[i]=a;
a+=c[i];
a++;
}
a--;
int dif=n-a;
if(dif==0){
int lst=0;
for (int i = 0; i < m; ++i)
{
for (int j = lst; j < lst+c[i]; ++j)
{
s[j]='X';
}
lst+=c[i];
if(lst<n) s[lst]='_';
lst++;
}
return s;
}
for (int i = 0; i < m; ++i)
{
if(c[i]>=dif){
for (int j = beg[i]+dif; j < beg[i]+c[i]; ++j)
{
s[j]='X';
}
}
}
return s;
}
/*int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
assert(1 == scanf("%s", buf));
std::string s = buf;
int c_len;
assert(1 == scanf("%d", &c_len));
std::vector<int> c(c_len);
for (int i = 0; i < c_len; i++) {
assert(1 == scanf("%d", &c[i]));
}
std::string ans = solve_puzzle(s, c);
printf("%s\n", ans.data());
return 0;
}*/