이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
bitset<200100> tran1[101],tran2,ok[101],ok2[101],wht,blk;
int sumblk[200100],prfblk[200100],prfwht[200100],n_;
inline int nowht(int l,int r){
return r<=n_&&prfwht[r]==prfwht[l-1];
}
inline int noblk(int l){
return !blk[l];
}
string solve_puzzle(string s, vector<int> c) {
int n=s.size(),k=c.size();
n_=n;
s=" "+s;
for(int i=1;i<=n;i++)
blk[i]=s[i]=='X',prfwht[i]=s[i]=='_';
for(int i=1;i<=n;i++)
prfblk[i]+=prfblk[i-01],prfwht[i]+=prfwht[i-1];
for(int i=1;i<=n;i++){
for(int j=0;j<k;j++)
tran1[j][i]=nowht(i,i+c[j]-1)&&noblk(i+c[j]);
tran2[i]=noblk(i);
}
ok[0][1]=1;
for(int i=1;i<=n;i++) {
if(tran2[i])for(int j=0;j<=k;j++)
ok[j][i+1]=ok[j][i+1]|ok[j][i];
for(int j=0;j<k;j++)if(tran1[j][i]&&ok[j][i])
ok[j+1][i+c[j]+1]=1;
}
ok2[k][n+1]=1;
ok2[k][n+2]=1;
for(int i=n+1;--i;){
if(tran2[i])for(int j=0;j<=k;j++)
ok2[j][i]=ok2[j][i+1]|ok2[j][i];
for(int j=0;j<k;j++)
if(tran1[j][i]&&ok2[j+1][i+c[j]+1])
ok2[j][i]=1;
}
for(int i=0;i<=k;i++)
ok[i]&=ok2[i];
for(int i=1;i<=n;i++){
if(tran2[i])for(int j=0;j<=k;j++)
wht[i]=wht[i]|ok[j][i]&ok[j][i+1];
for(int j=0;j<k;j++){
if(!ok[j][i])continue;
if(tran1[j][i]&&ok[j+1][i+c[j]+1])
sumblk[i]++,sumblk[i+c[j]]--,wht[i+c[j]]=1;
}
}
string str;
for(int i=1;i<=n;i++){
sumblk[i]+=sumblk[i-1];
if(wht[i]&&sumblk[i])
str+='?';
else if(sumblk[i])
str+='X';
else str+='_';
}
return str;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:45:35: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
45 | wht[i]=wht[i]|ok[j][i]&ok[j][i+1];
| ~~~~~~~~^~~~~~~~~~~
# | 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... |