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>
#ifndef ARTHUR_LOCAL
#include "paint.h"
#endif
using namespace std;
string solve_puzzle(string S, vector<int> C)
{
int n = S.size();
int k = C.size();
int c_sum=0;
for(auto c:C) c_sum += c;
if(c_sum + k - 1 == n)
{
int i=0;
for(auto c:C)
{
for(int d=1; d<=c; d++) S[i++]='X';
if(i<n) S[i++]='_';
}
return S;
}
for(int i=0; i<n; i++)
{
int cur = 0;
for(int j=0; j<k; j++)
{
cur += C[j];
if(cur + j > i)
{
int RHS=0;
RHS += c_sum;
RHS -= cur;
RHS += C[j];
RHS += (k-j)-1;
//if(i==2) cout << RHS << endl;
if(RHS <= n-i-1) S[i]='?';
else S[i]='X';
break;
}
}
if(S[i]=='.') S[i]='?';
}
return S;
}
#ifdef ARTHUR_LOCAL
int main()
{
cout << solve_puzzle("..........",{3,4}) << endl;
}
#endif
# | 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... |