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;
const int N=2e5+100;
int n,k;
string ss;
vector<int> cc;
int ok_(int u)
{
int lst=0,sum=0;
for(int i=0;i<n;i++){
int cnt=0;
for(int j=i;j<n;j++){
if(ss[j]=='.'&&j!=u){
cnt++;
}
else{
break;
}
}
if(sum+cnt>=cc[lst]){
sum++;
if(sum==cc[lst]){
lst++;
if(lst==k)return 1;
i++;
sum=0;
}
}
}
return 0;
}
int okxx(int u,int h)
{
int sum=0,lst=0;
for(int i=0;i<n;i++){
// cout<<i<<" "<<sum<<" "<<lst<<"\n";
int cnt=0;
int kkk=i-1;
for(int j=i;j<n;j++){
if(ss[j]!='_'){
cnt++;
kkk=j;
if(sum+cnt==cc[lst])break;
}
else{
break;
}
}
kkk++;
if(kkk==u)continue;
if(lst==h){
if(i+min(cnt-1,cc[lst]-1)>=u){
sum++;
}
if(i==u&&sum+cnt-1<cc[lst])return 0;
if(sum==cc[lst]){
lst++;
i++;
if(lst==k)return 1;
sum=0;
}
}
else{
if(i==u)return 0;
if(cnt+sum>=cc[lst]){
sum++;
if(sum==cc[lst]){
sum=0;
lst++;
i++;
if(lst==k)return 1;
}
}
}
}
return 0;
}
int okx(int u)
{
for(int h=0;h<k;h++){
if(okxx(u,h))return 1;
}
return 0;
}
string solve_puzzle(string s,vector<int> c){
string ans=s;
cc=c;
ss=s;
n=s.size();
k=c.size();
for(int i=0;i<n;i++){
if(s[i]!='.')continue;
int ok=0;
ok=okx(i);
ok+=2*ok_(i);
if(ok==1)ans[i]='X';
if(ok==2)ans[i]='_';
if(ok==3)ans[i]='?';
}
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... |