Submission #291613

#TimeUsernameProblemLanguageResultExecution timeMemory
291613MoNsTeR_CuBePaint By Numbers (IOI16_paint)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "paint.h" #include <cstdlib> using namespace std; #define int long long int n, k; vector< int > c; vector< vector< int > > memo; //ONLY works with empty cells vector< vector< int > > tot; vector< vector< int > > timee; int dp(int posArray, int posC){ /////////////////////////// if(posArray >= n){ if(posC < k) return 0; else{ return 1; } } if(posC >= k) return 1; /////////////////////////// if(memo[posArray][posC] != -1){ if(timee[posArray][posC])timee[posArray][posC]++; return memo[posArray][posC]; } /////////////////////////// memo[posArray][posC] = 0; tot[posArray][posC] = 0; if(posArray + c[posC] - 1 < n){ timee[posArray][posC]++; memo[posArray][posC] += dp(posArray + c[posC] + 1, posC+1); tot[posArray][posC] = memo[posArray][posC]; } memo[posArray][posC] += dp(posArray+1, posC); return memo[posArray][posC]; /////////////////////////// } vector< int > ans; vector< vector< bool > > visited; void rec(int posArray, int posC){ if(posArray >= n){ return ; } if(posC >= k) return; //if(visited[posArray][posC]) return ; if(posArray + c[posC]-1 < n ){ //cout << "AT " << posArray << ' ' << posC << ' ' << "Add " << tot[posArray][posC] << ' ' << "From " << posArray << ' ' << "TO " << posArray+c[posC]-1 << ' ' << "TIME " << timee[posArray][posC] << endl; ans[posArray] += tot[posArray][posC]; ans[posArray+c[posC]]-=tot[posArray][posC]; } rec(posArray + c[posC] + 1, posC+1); rec(posArray+1, posC); visited[posArray][posC] = true; } #undef int string solve_puzzle(string s, vector<int> C){ #define int long long n = s.size(); k = C.size(); c.resize(k); memo.assign(n, vector< int> (k,-1)); c = C; tot.assign(n, vector< int> (k,-1)); timee.assign(n, vector< int> (k,0)); dp(0,0); ans.assign(n+1,0); visited.assign(n+1, vector< bool > (k,false)); rec(0,0); string rep = ""; for(int i = 1; i < n; i++){ ans[i] += ans[i-1]; } for(int i = 0; i < n; i++){ if(ans[i] == dp(0,0)) rep += 'X'; else if(ans[i]) rep += '?'; else rep += '_'; } return rep; } /* signed main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> n >> k; c.resize(k); memo.assign(n, vector< int> (k,-1)); for(int i = 0; i < k; i++){ cin >> c[i]; } string s = "";; for(int i = 0; i < n; i++) s += '.'; cout << solve_puzzle(s,c) << endl; } */

Compilation message (stderr)

paint.cpp: In function 'std::string solve_puzzle(std::string, std::vector<int>)':
paint.cpp:75:10: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>')
   75 |      c = C;
      |          ^
In file included from /usr/include/c++/9/vector:72,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from paint.cpp:1:
/usr/include/c++/9/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from paint.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:706:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:706:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  706 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:727:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  727 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:727:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  727 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~