제출 #537901

#제출 시각아이디문제언어결과실행 시간메모리
537901timreizinPaint By Numbers (IOI16_paint)C++17
7 / 100
0 ms212 KiB
#include "paint.h" using namespace std; string solve_puzzle(string s, vector<int> c) { int n = (int)s.size(), k = c.size(); vector dpWR(n + 1, vector(k + 1, false)), dpBR(n + 1, vector(k + 1, false)), dpWL(n + 2, vector(k + 1, false)), dpBL(n + 2, vector(k + 1, false)); vector<int> pref(n + 1); for (int i = 0; i < n; ++i) pref[i + 1] = pref[i] + (s[i] == '_'); dpWR[0][0] = 1; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= k; ++j) { if (s[i - 1] != '_' && j != k && i - c[j] >= 0 && pref[i] - pref[i - c[j]] == 0) dpBR[i][j] = dpWR[i - c[j]][j]; if (s[i - 1] != 'X') dpWR[i][j] = dpWR[i - 1][j] | (j == 0 ? 0 : dpBR[i - 1][j - 1]); } } dpWL[n + 1][k] = 1; for (int i = n; i >= 1; --i) { for (int j = 0; j <= k; ++j) { if (s[i - 1] != '_' && j != k && i + c[j] <= n + 1 && pref[i + c[j] - 1] - pref[i - 1] == 0) dpBL[i][j] = dpWL[i + c[j]][j + 1]; if (s[i - 1] != 'X') dpWL[i][j] = dpWL[i + 1][j] | dpBL[i + 1][j]; } } vector<vector<int>> works(k); for (int i = 1; i <= n; ++i) for (int j = 0; j < k; ++j) if (i + c[j] - 1 <= n && dpBL[i][j] && dpBR[i + c[j] - 1][j]) works[j].push_back(i); vector<int> inds(k); for (int i = 1; i <= n; ++i) { bool checkW = false, checkB = false; for (int j = 0; j <= k; ++j) { checkW |= dpWR[i][j] && dpWL[i][j]; if (j < k) { /*auto it = lower_bound(works[j].begin(), works[j].end(), i + 1 - c[j]); if (it != works[j].end()) checkB |= *it <= i;*/ while (inds[j] != works[j].size() && works[j][inds[j]] < i + 1 - c[j]) ++inds[j]; checkB |= works[j][inds[j]] <= i; } } if (checkB && checkW) s[i - 1] = '?'; else if (checkB) s[i - 1] = 'X'; else s[i - 1] = '_'; } return s; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:42:32: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |                 while (inds[j] != works[j].size() && works[j][inds[j]] < i + 1 - c[j]) ++inds[j];
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...