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>
using namespace std;
typedef vector<int> vi;
vi v;
vi d;
int n,k;
void solve(int u, int o, int j, int sum){
int u1=u;
if(sum>n) return;
for(int i=u1; i<u1+o; i++){
if(u>=n) return;
if(v[i]==2){
v[i]=3;
}else{
if(v[i]!=3) v[i]=1;
}
u++;
}
if(u>=n) return;
u1=u;
for(int i=u1; i<u1+d[j]; i++){
//cout<<u<<" "<<d[j]<<endl;
if(u>=n) return;
if(v[i]==1){
v[i]=3;
}else{
if(v[i]!=3) v[i]=2;
}
u++;
}
j++;
if(j>=k){
for(int i=u1+d[j-1]; i<n; i++){
if(v[i]==2){
v[i]=3;
}else{
if(v[i]!=3) v[i]=1;
}
}
}
for(int i=1; i<n; i++){
/* for(int i=0; i<n; i++){
cout<<v[i]<<" ";
}
cout<<endl;*/
solve(u,i,j,sum+i-1);
}
}
string solve_puzzle(string s, vi c) {
k = (int)c.size();
n = (int)s.size();
v.resize(n,0);
int sum=0;
d=c;
for(int i=0; i<k; i++){
sum+=c[i]+1;
}
sum--;
for(int i=0; i<n; i++){
/* for(int i=0; i<n; i++){
cout<<v[i]<<" ";
}*/
//cout<<endl;
solve(0,i,0,sum+i);
}
string ans;
for(int i=0; i<n; i++){
if(v[i]==1){
ans+='_';
}
if(v[i]==2){
ans+='X';
}
if(v[i]==3){
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... |