Submission #1050971

#TimeUsernameProblemLanguageResultExecution timeMemory
1050971fv3Paint By Numbers (IOI16_paint)C++14
Compilation error
0 ms0 KiB
#include"paint.h" #include<bits/stdc++.h> using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:3:119: error: no match for 'operator+' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                    ~~ ^ ~
      |                                                                                                                    |    |
      |                                                                                                                    int  std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:508:5: note: candidate: 'template<class _Iterator> std::reverse_iterator<_Iterator> std::operator+(typename std::reverse_iterator<_Iterator>::difference_type, const std::reverse_iterator<_Iterator>&)'
  508 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:508:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:67,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/string:40,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/stl_iterator.h:1540:5: note: candidate: 'template<class _Iterator> std::move_iterator<_IteratorL> std::operator+(typename std::move_iterator<_IteratorL>::difference_type, const std::move_iterator<_IteratorL>&)'
 1540 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/10/bits/stl_iterator.h:1540:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:55,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6022:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6022 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6022:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:56,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1160 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1160:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   mismatched types 'const _CharT*' and 'int'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:56,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(_CharT, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 1180 |     operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.tcc:1180:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   deduced conflicting types for parameter '_CharT' ('int' and 'char')
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:55,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6059:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)'
 6059 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6059:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:55,
                 from paint.h:3,
                 from paint.cpp:1:
/usr/include/c++/10/bits/basic_string.h:6075:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::operator+(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 6075 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/10/bits/basic_string.h:6075:5: note:   template argument deduction/substitution failed:
paint.cpp:3:121: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    3 | using namespace std;string solve_puzzle(string s, vector<int> c){const int K = c.size();const int N = s.size();s = 95 + s + 95;vector<int> preSum(N+3);for (int i = 0; i <= N + 2; i++)preSum[i+1] = preSum[i] + (int)(s[i] ==95);vector<vector<int>>DP_r(N+2,vector<int>(K+1));DP_r[0][0] = 1;for (int i = 0; i <= N; i++){if (s[i] == 88) continue;for (int k = 0; k <= K; k++){if (!DP_r[i][k]) continue;if (s[i + 1] != 88)DP_r[i+1][k] = 1;if (k == K || i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;DP_r[i + c[k] + 1][k + 1] = 1;}}vector<vector<int>> DP_l(N+2,vector<int>(K+1));DP_l[N+1][K] = 1;for (int i = N+1; i >= 1; i--){if (s[i] == 88)continue;for (int k = 0; k <= K; k++){if (!DP_l[i][k]) continue;if (s[i - 1] != 'X')DP_l[i-1][k] = 1;if (k == 0 || i - c[k-1] - 1 < 0) continue;if (preSum[i] - preSum[i - c[k-1]]) continue;if (s[i - c[k-1] - 1] == 88) continue;DP_l[i - c[k-1] - 1][k - 1] = 1;}}vector<int> ps(N+2);for (int i = 0; i < N + 2; i++){if (s[i] == 88) continue;for (int k = 0; k < K; k++){if (i + c[k] + 1 >= N + 2 || !DP_r[i][k] || !DP_l[i + c[k] + 1][k+1]) continue;if (i + c[k] + 1 >= N + 2) continue;if (preSum[i + c[k] + 1] - preSum[i + 1]) continue;if (s[i + c[k] + 1] == 88) continue;ps[i+1]++;ps[i+c[k]+1]--;}}string res;int sum = 0;for (int i = 1; i <= N; i++){sum += ps[i];if (s[i] == 88){res += 88;continue;}if (sum){bool ok = true;for (int k = 0; k <= K; k++){if (!DP_r[i][k] || !DP_l[i][k])ok = false;res += 63;break;}if (ok) res += 88;}else res += 95;}return res;}
      |                                                                                                                         ^
In file included from /usr/include/c++/10/string:55,