이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
int x[200001];
int y[200001];
int dp[200001][101];
string solve_puzzle(string s,vector<int> c){
int n,m,o,p,q,r;
n=s.size();
m=c.size();
s='/'+s;
for(int i=dp[0][0]=1;i<=n;i++){
x[i]=x[i-1]+(s[i]=='X');
y[i]=y[i-1]+(s[i]=='_');
if(!x[i]) dp[i][0]=1;
}
for(int j=1;j<=m;j++){
for(int i=c[j-1];i<=n;i++){
if(j==m && x[n]>x[i]) continue;
if(s[i]=='X'){
dp[i][j]=dp[max(i-c[j-1]-1,0)][j-1];
if(y[i]>y[i-c[j-1]] || s[i-c[j-1]]=='X')
dp[i][j]=0;
}
else{
dp[i][j]=dp[max(i-c[j-1]-1,0)][j-1];
if(dp[i-1][j]) dp[i][j]=1;
if(y[i]>y[i-c[j-1]] || s[i-c[j-1]]=='X')
dp[i][j]=dp[i-1][j];
}
}
}
//for(int j=1;j<=m;j++){
// for(int i=1;i<=n;i++)
// cout<<dp[i][j]<<' ';
// cout<<endl;
//}
o=r=n;
for(int j=m;j>0;j--){
p=1;
q=o;
for(int i=c[j-1];i<=o;i++){
if(y[i]==y[i-c[j-1]] && s[i-c[j-1]]!='X'
&& dp[max(i-c[j-1]-1,0)][j-1]){
p=i-c[j-1]+1;
q=min(q,i);
}
}
for(int i=p;i<=q;i++)
s[i]='X';
for(int i=p+c[j-1];i<=r;i++)
s[i]='_';
o=p-2;
r=q-c[j-1];
}
s.erase(s.begin(),s.begin()+1);
for(int i=0;i<n;i++)
if(s[i]=='.') s[i]='?';
return s;
}
# | 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... |