제출 #1205535

#제출 시각아이디문제언어결과실행 시간메모리
1205535tamzid모자이크 (IOI24_mosaic)C++20
컴파일 에러
0 ms0 KiB
#include "mosaic.h" #include <vector> std::vector<long long> mosaic(std::vector<int> X, std::vector<int> Y, std::vector<int> T, std::vector<int> B, std::vector<int> L, std::vector<int> R) { int Q = (int)T.size(); std::vector<long long> C(Q, 0); int n = X.size(); std::vector<std::vector<int>> grid(n,std::vector<int>(n)); for(int i=0;i<n;++i) { grid[i][0] = Y[i]; } for(int i=0;i<n;++i) { grid[0][i] = X[i]; } for(int i=1;i<n;++i) { for(int j=1;j<n;++j) { grid[i] = (grid[i-1][j] == 0 && grid[i][j-1] == 0 ? 1 : 0); } } for(int k=0;k<Q;++k) { int cnt = 0; for(int i=T[k];i<=B[k];++i) { for(int j=L[k];j<=R[k];++j) { if(grid[i][j]) { ++cnt; } } } C[k] = cnt; } return C; }

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

mosaic.cpp: In function 'std::vector<long long int> mosaic(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
mosaic.cpp:27:64: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'int')
   27 |       grid[i] = (grid[i-1][j] == 0 && grid[i][j-1] == 0 ? 1 : 0);
      |                                                                ^
In file included from /usr/include/c++/11/vector:72,
                 from mosaic.h:1,
                 from mosaic.cpp:1:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from mosaic.h:1,
                 from mosaic.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~