이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "paint.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back()
#define ss second
#define ff first
#define mt make_tuple
#define pof pop_front()
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
using pll = pair <ll, ll>;
using pii = pair <int, int>;
int dp[100005][101], wh[100001], rdp[100005][101], canw[100005], canb[100005];
string ans;
string solve_puzzle(string s, vector<int> c) {
c.insert(c.begin(), 0);
for (int i = 1; i < s.size(); i++) {
wh[i] = wh[i - 1];
if ( s[i] == '_' )
wh[i]++;
}
s = '0' + s + '0';
for (int i = 0; i < s.size(); i++) {
if ( s[i] == 'X' )
break;
dp[i][0] = 1;
}
for (int i = 1; i < c.size(); i++) {
for (int j = 1; j < s.size() - 1; j++) {
if ( s[j] == '_' )
dp[j][i] = dp[j - 1][i];
else if ( s[j] == 'X' ) {
if ( j >= c[i] && s[j - c[i]] != 'X' && dp[max(j - c[i] - 1, 0)][i - 1] )
dp[j][i] = 1;
} else {
if ( dp[j - 1][i] || (j >= c[i] && s[j - c[i]] != 'X' && dp[max(j - c[i] - 1, 0)][i - 1]) )
dp[j][i] = 1;
}
}
}
for (int i = s.size(); i >= 0; i--) {
if ( s[i] == 'X' )
break;
rdp[i][0] = 1;
}
for (int i = 1; i < c.size(); i++) {
for (int j = s.size() - 2; j > 0; j--) {
if ( s[j] == '_' )
rdp[j][i] = rdp[j + 1][i];
else if ( s[j] == 'X' ) {
if ( s.size() - j >= c[c.size() - i] )
if ( s[j + c[c.size() - i]] != 'X' && rdp[j + c[c.size() - i] + 1][i - 1] )
rdp[j][i] = 1;
} else {
if ( rdp[j + 1][i] || (s.size() - j >= c[c.size() - i] && s[j + c[c.size() - i]] != 'X' && rdp[j + c[c.size() - i] + 1][i - 1]) )
rdp[j][i] = 1;
}
}
}
for (int i = 1; i < s.size() - 1; i++)
for (int j = 0; j < c.size(); j++)
if ( s[i] != 'X' && dp[i - 1][j] && rdp[i + 1][c.size() - j - 1] )
canw[i] = 1;
for (int i = 1; i < s.size() - 1; i++)
for (int j = 1; j < c.size(); j++)
if ( s[i] != '_' && i >= c[j] && wh[i] - wh[i - c[j]] == 0 && s[i - c[j]] != 'X' && dp[max(i - c[j] - 1, 0)][j - 1] && s[i + 1] != 'X' && rdp[i + 2][c.size() - j - 1] )
canb[i]++, canb[i - c[j]]--;
for (int i = s.size() - 1; i > 0; i--)
canb[i] += canb[i + 1];
for (int i = 1; i < s.size() - 1; i++) {
if ( canw[i] && canb[i] )
ans += '?';
else if ( canw[i] )
ans += '_';
else
ans += 'X';
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
paint.cpp: In function 'std::__cxx11::string solve_puzzle(std::__cxx11::string, std::vector<int>)':
paint.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < s.size(); i++) {
~~^~~~~~~~~~
paint.cpp:39:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < s.size(); i++) {
~~^~~~~~~~~~
paint.cpp:46:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < c.size(); i++) {
~~^~~~~~~~~~
paint.cpp:47:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < s.size() - 1; j++) {
~~^~~~~~~~~~~~~~
paint.cpp:70:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < c.size(); i++) {
~~^~~~~~~~~~
paint.cpp:76:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if ( s.size() - j >= c[c.size() - i] )
paint.cpp:81:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if ( rdp[j + 1][i] || (s.size() - j >= c[c.size() - i] && s[j + c[c.size() - i]] != 'X' && rdp[j + c[c.size() - i] + 1][i - 1]) )
paint.cpp:87:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < s.size() - 1; i++)
~~^~~~~~~~~~~~~~
paint.cpp:88:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < c.size(); j++)
~~^~~~~~~~~~
paint.cpp:92:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < s.size() - 1; i++)
~~^~~~~~~~~~~~~~
paint.cpp:93:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 1; j < c.size(); j++)
~~^~~~~~~~~~
paint.cpp:101:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i < s.size() - 1; 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... |