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 "grader.cpp"
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
#define puu pair <ull, ull>
using namespace std;
const ll N=1e5+10;
const ll mod=1e9+7;
string s1="";
bool check(string s,vector<int>c,int l){
int k=0,ind=0;
for(int i=0;i<(int)s.size();i++){
if(s[i]=='X')k++;
else if(k){
if(k!=c[ind]){
return false;
}
ind++;
k=0;
}
}
if(k){
if(k!=c[ind]){
return false;
}
ind++;
k=0;
}
if(ind!=l)return false;
return true;
}
void func(int i,int n ,string s,vector<int>c,int k){
if(i==n){
if(s1=="" && check(s,c,k)){
s1=s;
}
if(check(s,c,k)){
for(int i=0;i<n;i++){
if((s[i]=='X' && s1[i]=='_') || (s[i]=='_' && s1[i]=='X'))s1[i]='?';
else if(s1[i]!='?')s1[i]=s[i];
}
}
return;
}
else{
if(s[i]=='.'){
s[i]='X';
func(i+1,n,s,c,k);
s[i]='_';
}
func(i+1,n,s,c,k);
}
return;
}
string solve_puzzle(string s,vector<int>c){
int n=s.size();
int k=c.size();
func(0,n,s,c,k);
return s1;
}
/*
*/
# | 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... |