제출 #258547

#제출 시각아이디문제언어결과실행 시간메모리
258547ChrisTPaint By Numbers (IOI16_paint)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; string solve_puzzle (string s, int k, int *c) { int n = s.length(); s = 'X' + s + 'X'; vector<vector<bool>> dp(n+2,vector<bool>(k+1)), dp2(n+2,vector<bool>(k+1)); vector<int> psa(n+1); for (int i = 1; i <= n; i++) psa[i] = psa[i-1] + (s[i] == '_'); dp[0][0] = 1; for (int i = 1; i <= n; i++) { if (s[i] != 'X') dp[i][0] = dp[i-1][0]; if (s[i] != 'X') dp[i][1] = dp[i-1][1]; if (i >= c[0] && psa[i] == psa[i-c[0]]) dp[i][1] = dp[i][1] | dp[i-c[0]][0]; for (int j = 2; j <= k; j++) { if (s[i] != 'X') dp[i][j] = dp[i-1][j]; if (i - c[j-1] >= 1 && psa[i] == psa[i-c[j-1]] && s[i-c[j-1]] != 'X') dp[i][j] = dp[i][j] | dp[i-c[j-1]-1][j-1]; } } dp2[n+1][0] = 1; for (int i = n; i >= 1; i--) { if (s[i] != 'X') dp2[i][0] = dp2[i+1][0]; if (s[i] != 'X') dp2[i][1] = dp2[i+1][1]; if (i + c[k-1] - 1 <= n && psa[i + c[k-1] - 1] == psa[i-1]) dp2[i][1] = dp2[i][1] | dp2[i+c[k-1]][0]; for (int j = 2; j <= k; j++) { if (s[i] != 'X') dp2[i][j] = dp2[i+1][j]; if (i + c[k-j] <= n && psa[i+c[k-j]-1] == psa[i-1] && s[i+c[k-j]] != 'X') dp2[i][j] = dp2[i][j] | dp2[i+c[k-j]+1][j-1]; } } vector<int> diff(n+2); for (int j = 1; j <= k; j++) { for (int i = 1; i + c[j-1] - 1 <= n; i++) if (psa[i+c[j-1]-1]==psa[i-1]&& (j == 1 || s[i-1] != 'X') && (j == k || s[i + c[j-1]] != 'X') && dp[i-1-(j!=1)][j-1] && dp2[i+c[j-1]+(j!=k)][k-j]){ diff[i]++; diff[i+c[j-1]]--; } } for (int i = 1; i <= n; i++) { diff[i] += diff[i-1]; bool white = 0, black = diff[i]; for (int j = 0; j <= k; j++) { white |= s[i] != 'X' && dp[i-1][j] && dp2[i+1][k-j]; } assert(white || black); s[i] = white && black ? '?' : (white ? '_' : 'X'); } return s.substr(1,n); }

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

/tmp/ccY2zlvp.o: In function `main':
grader.cpp:(.text.startup+0x1eb): undefined reference to `solve_puzzle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status