이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,pdp[200005][102],sdp[200005][102],A[200005],B[200005],C[200005];
string s1;
std::string solve_puzzle(std::string s, std::vector<int> c) {
s='*'+s;
pdp[0][0]=1;
for(long long i=1;i<s.size();i++) {
if(s[i]=='X') a++;
if(a==0) pdp[i][0]=1;
}
a=0;
for(long long i=1;i<s.size();i++) {
if(s[i]=='_') A[i]=A[i-1]+1;
else A[i]=A[i-1];
for(long long j=0;j<c.size();j++) {
if(pdp[i-1][j+1]==1) { pdp[i][j+1]=1; continue; }
if(A[i]-A[i-c[j]]!=0) continue;
if(i<c[j]) continue;
if(i!=s.size()-1 && s[i+1]=='X') continue;
if(s[i-c[j]]=='X') continue;
if(i==c[j] && j!=0) continue;
if(i==c[j]) {
if(A[i]==0) pdp[i][j+1]=1;
continue;
}
pdp[i][j+1]=pdp[i-c[j]-1][j];
}
}
for(long long i=s.size()-1;i>=0;i--) {
if(s[i]=='X') a++;
if(a==0) sdp[i][c.size()+1]=1;
}
a=0;
for(long long i=s.size()-1;i>=1;i--) {
if(s[i]=='_') A[i]=A[i+1]+1;
else A[i]=A[i+1];
for(long long j=c.size()-1;j>=0;j--) {
if(sdp[i+1][j+1]==1) { sdp[i][j+1]=1; continue; }
if(A[i]-A[i+c[j]]!=0) continue;
if(s.size()-i<c[j]) continue;
if(i!=1 && s[i-1]=='X') continue;
if(s[i+c[j]]=='X') continue;
if(i==s.size()-c[j] && j!=c.size()-1) continue;
if(i==s.size()-c[j]) {
if(A[i]==0) sdp[i][j+1]=1;
continue;
}
sdp[i][j+1]=sdp[i+c[j]+1][j+2];
}
}
sdp[s.size()][c.size()+1]=1;
for(long long i=1;i<s.size();i++) {
if(s[i]=='X') continue;
if(s[i]=='_') { B[i]=1; continue; }
for(long long j=-1;j<c.size();j++) {
if(pdp[i-1][j+1]==1 && sdp[i+1][j+2]==1) B[i]=1;
}
}
for(long long i=1;i<s.size();i++) {
A[i]=A[i-1];
if(s[i]=='_') { A[i]++; continue; }
for(long long j=0;j<c.size();j++) {
if(i<c[j]) continue;
if(pdp[i][j+1]==0) continue;
if(A[i]-A[i-c[j]]!=0) continue;
if(s[i-c[j]]=='X') continue;
if(s[i+1]=='X') continue;
if(j==0 && i==c[j] && sdp[i+2][j+2]==1) { C[i+1]--; C[i-c[j]+1]++; continue; }
if(j==c.size()-1 && pdp[i-c[j]-1][j]==1) { C[i+1]--; C[i-c[j]+1]++; continue; }
if(pdp[i-c[j]-1][j]==1 && sdp[i+2][j+2]==1) { C[i+1]--; C[i-c[j]+1]++; }
}
}
for(long long i=1;i<s.size();i++) {
C[i]+=C[i-1];
}
for(long long i=1;i<s.size();i++) {
if(B[i]==1 && C[i]!=0) s1+='?';
else if(B[i]==1) s1+="_";
else if(C[i]!=0) s1+="X";
}
return s1;
}/*
int main() {
solve_puzzle("..........", {3,4});
}*/
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:9:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
paint.cpp:14:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
paint.cpp:17:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for(long long j=0;j<c.size();j++) {
| ~^~~~~~~~~
paint.cpp:21:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | if(i!=s.size()-1 && s[i+1]=='X') continue;
| ~^~~~~~~~~~~~
paint.cpp:42:26: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
42 | if(s.size()-i<c[j]) continue;
paint.cpp:45:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(i==s.size()-c[j] && j!=c.size()-1) continue;
paint.cpp:45:41: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if(i==s.size()-c[j] && j!=c.size()-1) continue;
| ~^~~~~~~~~~~~
paint.cpp:46:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if(i==s.size()-c[j]) {
paint.cpp:54:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
paint.cpp:57:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(long long j=-1;j<c.size();j++) {
| ~^~~~~~~~~
paint.cpp:61:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
paint.cpp:64:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(long long j=0;j<c.size();j++) {
| ~^~~~~~~~~
paint.cpp:71:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | if(j==c.size()-1 && pdp[i-c[j]-1][j]==1) { C[i+1]--; C[i-c[j]+1]++; continue; }
| ~^~~~~~~~~~~~
paint.cpp:75:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
paint.cpp:78:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(long long i=1;i<s.size();i++) {
| ~^~~~~~~~~
# | 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... |