이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "paint.h"
using namespace std;
#define pb push_back
string solve_puzzle(string s, vector<int> c)
{
int n = (int)s.length();
int k = (int)c.size();
string res = s;
int i = 0, clue = 0;
while(i<n&&clue<k)
{
int temp = c[clue];
while(i<n&&temp>0)
{
res[i] = 'X';
i++;
temp--;
}
if(i<n)
res[i] = '_';
i++;
clue++;
}
while(i<n)
res[i++] = '_';
vector<int> pos;
i = 0;
while(i<n)
{
if(res[i]=='X')
{
pos.pb(i);
while(i<n&&res[i]=='X')
i++;
}
i++;
}
vector<int> visited(n, 0);
for(int j = 0; j<n; j++)
{
if(res[j]=='X')
visited[j] = 2;
else
visited[j] = 1;
}
for(int p = k-1; p>=0; p--)
{
int position = pos[p];
int len = c[p];
while(position+len<n)
{
if(position+len-1<n-2)
{
if(res[position+len]=='_'&&res[position+len+1]=='X')
break;
}
res[position] = '_';
res[position+len] = 'X';
position++;
for(int j = 0; j<n; j++)
{
if(visited[j]==1&&res[j]=='X')
visited[j]=3;
else if(visited[j]==2&&res[j]=='_')
visited[j]=3;
}
}
}
string fin = "";
for(int j = 0; j<n; j++)
{
if(visited[j]==1)
fin.pb('_');
else if(visited[j]==2)
fin.pb('X');
else
fin.pb('?');
}
return fin;
}
# | 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... |