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"
#define MAX 110
using namespace std;
int N, K;
string ans;
vector<int> blocks;
std::string solve_puzzle(string s, std::vector<int> c)
{
N = s.size();
K = c.size();
for(int g = 0 ; g < N ; g++)
ans[g] = 'p';
for(int g = 0 ; g < N ; g++)
if(s[g] == '_')
blocks.push_back(g);
int l = 0;
int indClue = 0;
int indBlocked = 0;
while(l < N && s[l] == '_')
l++, indBlocked++;//primeiro que posso colocar
//printf("l = %d indBlocked = %d %d\n",l,indBlocked,blocks.front());
while(indClue < K)
{
//printf("oiii\n");
while(indBlocked < blocks.size() && (-(l - blocks[indBlocked]) < c[indClue]))
{
//printf("tra %d %d %d\n",l,blocks[indBlocked],c[indClue]);
l = blocks[indBlocked] + 1;
indBlocked++;
}
for(int g = l ; g < l + c[indClue] ; g++)
ans[g] = 'X';
l += c[indClue] + 1;
indClue++;
//printf("l = %d indb = %d indc = %d\n",l,indBlocked,indClue);
}
for(int g = 0 ; g < N ; g++)
if(ans[g] == 'p')
ans[g] = '_';
//printf("%s\n",ans.c_str());
return ans;
}
/*int main()
{
string l;
int cc;
int n1;
vector<int> ll;
cin >> l;
cin >> cc;
for(int g = 0 ; g < cc ; g++)
{
scanf("%d",&n1);
ll.push_back(n1);
}
printf("%s\n",solve_puzzle(l , ll).c_str());
}*/
Compilation message (stderr)
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(indBlocked < blocks.size() && (-(l - blocks[indBlocked]) < c[indClue]))
~~~~~~~~~~~^~~~~~~~~~~~~~~
# | 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... |