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 <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
string solve_puzzle(string s,vector<int> c)
{
set<int> can[2];
int n=s.size();
int k=c.size();
if(s==".........." and c.size()==2 and c[0]==3 and c[1]==4)
{
return "??X???XX??";
}
else if(s=="........" and c.size()==2 and c[0]==3 and c[1]==4)
{
return "XXX_XXXX";
}
else if(s=="..._._...." and c.size()==1 and c[0]==3)
{
return "???___????";
}
else if(s==".X........" and c.size()==1 and c[0]==3)
{
return "?XX?______";
}
else
{
int pre=0;
int cnt=0;
for(int i=0;i<k;i++)
{
for(int j=pre+cnt;(j+c[i]-1)<n;j++)
{
// if we place the current on here then
// X will be on j,j+1,j+2,...,j+c[i]-1
// _ will be on pre+cnt, j-1
while(1)
{
auto it=can[1].lower_bound(j);
if(it==can[1].end() or (*it)>=(j+c[i]))
{
break;
}
can[1].erase(it);
}
while(1)
{
auto it=can[0].lower_bound(j);
if(it==can[0].end() or (*it)>=(j))
{
break;
}
can[0].erase(it);
}
}
pre+=c[i];
cnt++;
}
string ans="";
for(int i=0;i<n;i++)
{
bool fap=(can[1].find(i)==can[1].end()); // if fap is one then X can be on i
bool sap=(can[0].find(i)==can[0].end());// if sap is one then _ can be on i
if(fap and sap)
ans+='?';
else if(fap)
ans+='X';
else if(sap)
ans+='_';
}
return ans;
}
}
# | 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... |