이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+50;
const int maxk = 110;
int n;
vector<int> c;
string s;
int dp[maxk][maxk][maxk];
bool can[maxn][2];
int calc(int idx,int at,int len){
if(at == c.size() && len)return 0;
if(len > c[at])return 0;
if(at != c.size() && len == c[at] && idx == n)at++;
if(idx == n)return (at == (int)c.size());
int &res = dp[idx][at][len];
if(res != -1)return res;
if(s[idx] == 'X')res = calc(idx+1,at,len+1);
else if(s[idx] == '_'){
if(!len)res = calc(idx+1,at,len);
else if(at == c.size() && len || len != c[at])return 0;
else res = calc(idx+1,at+1,0);
}else{
if(!len)res = calc(idx+1,at,len);
else if(at == c.size() && len || len != c[at])res = 0;
else res = calc(idx+1,at+1,0);
if(res)can[idx][1] = 1;
res |= calc(idx+1,at,len+1);
if(calc(idx+1,at,len+1))can[idx][0] = 1;
}
return res;
}
string solve_puzzle(string S, vector<int> C){
memset(dp,-1,sizeof(dp));
n = S.size();
c = C;
s = S;
calc(0,0,0);
string ans;
for(int i=0;i<n;i++){
if(s[i] == '.'){
if(can[i][0] && can[i][1])ans += '?';
else if(can[i][1])ans += '_';
else ans += 'X';
}else ans += s[i];
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'int calc(int, int, int)':
paint.cpp:17:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(at == c.size() && len)return 0;
~~~^~~~~~~~~~~
paint.cpp:19:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(at != c.size() && len == c[at] && idx == n)at++;
~~~^~~~~~~~~~~
paint.cpp:26:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(at == c.size() && len || len != c[at])return 0;
~~~^~~~~~~~~~~
paint.cpp:26:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
else if(at == c.size() && len || len != c[at])return 0;
~~~~~~~~~~~~~~~^~~~~~
paint.cpp:30:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(at == c.size() && len || len != c[at])res = 0;
~~~^~~~~~~~~~~
paint.cpp:30:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
else if(at == c.size() && len || len != c[at])res = 0;
~~~~~~~~~~~~~~~^~~~~~
# | 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... |