답안 #977779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977779 2024-05-08T11:00:50 Z Circling L-triominoes (CEOI21_ltriominoes) C++17
컴파일 오류
0 ms 0 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


bool tilable(int n, int bma, int bmb){
    vector<bool> a, b;
    for (int i = 0; i < n; i++){
        a.push_back((bma >> i) % 2);
        b.push_back((bmb >> i) % 2);
    }
    int currpos = 0;
    while (currpos < n){
        if (!a[currpos] && !b[currpos]) currpos++;
        else if (a[currpos] && b[currpos]){
            if (currpos == n - 1) return false;
            else if (a[currpos + 1]) a[currpos + 1] = 0;
            else if (b[currpos + 1]) b[currpos + 1] = 0;
            else return false;
            currpos++;
        } else {
            if (currpos == n - 1) return false;
            else if (a[currpos + 1] && b[currpos + 1]) currpos += 2;
            else return false;
        }
    }
    return true;
}


vector<vector<bool>> matmul(vector<vector<bool>> a, vector<vector<bool>> b){
    vector<vector<bool>> result;
    result.resize(a.size());
    for (int i = 0; i < a.size(); i++) result[i].resize(b.size());
    for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) result[j] = 0;
    for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) for (int k = 0; k < b[0].size(); k++) result[i][k] = result[i][k] || (result[i][j] && result[j][k]);
    return result;
}


vector<vector<bool>> matexp(vector<vector<bool>> a, int64_t k){
    vector<vector<bool>> result[a.size()][a.size()];
    if (k == 0){
        for (int i = 0; i < a.size(); i++) for (int j = 0; j < a.size(); j++) result[i][j] = i == j;
        return result;
    }
    result = matexp(matmul(a, a), k / 2);
    if (k % 2 == 1) result = matmul(result, a);
    return result;
}


int main(){
    int64_t w, h, k, currpos = 0, currblock;
    pair<int, int> blocked[250];
    cin >> w >> h >> k;
    if ((w * h - k) % 3 == 0){
        cout << "NO";
        return;
    }
    for (int i = 0; i < k; i++) cin >> blocked[i].first >> blocked[i].second;
    sort(blocked, blocked + n);
    vector<vector<bool>> transition;
    transition.resize(1 << w);
    for (int i = 0; i < (1 << w); i++){
        transition[i].resize(1 << w);
        for (int j = 0; j < (1 << w); j++) transition[i][j] = tilable(w, i, (1 << w) - 1 - j);
    }
    vector<vector<bool>> curr[1][1 << w];
    for (int i = 0; i < w; i++) curr[i] = i == 0;
    while (currblock < n){
        curr = matmul(curr, matexp(transition, blocked[currblock].second - 1 - currpos));
        for (int i = 0; i < 1 << w; i++){
            if ((i >> (blocked[currblock].second - 1)) % 2 == 0){
                curr[0][i + (1 << (blocked[currblock].second - 1))] = curr[0][i];
                curr[0][i] = 0;
            }
        }
    }
    curr = matmul(curr, matexp(transition, h - currpos));
    if (curr[0][0]) cout << "YES";
    else cout << "NO";
}

Compilation message

ltrominoes.cpp: In function 'std::vector<std::vector<bool> > matmul(std::vector<std::vector<bool> >, std::vector<std::vector<bool> >)':
ltrominoes.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < a.size(); i++) result[i].resize(b.size());
      |                     ~~^~~~~~~~~~
ltrominoes.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) result[j] = 0;
      |                     ~~^~~~~~~~~~
ltrominoes.cpp:54:58: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) result[j] = 0;
      |                                                        ~~^~~~~~~~~~
ltrominoes.cpp:54:87: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<bool> >, std::vector<bool> >::value_type' {aka 'std::vector<bool>'} and 'int')
   54 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) result[j] = 0;
      |                                                                                       ^
In file included from /usr/include/c++/10/vector:68,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from ltrominoes.cpp:15:
/usr/include/c++/10/bits/stl_bvector.h:740:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  740 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:740:31: note:   no known conversion for argument 1 from 'int' to 'const std::vector<bool>&'
  740 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_bvector.h:771:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  771 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:771:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<bool>&&'
  771 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_bvector.h:796:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  796 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_bvector.h:796:40: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<bool>'
  796 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~
ltrominoes.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) for (int k = 0; k < b[0].size(); k++) result[i][k] = result[i][k] || (result[i][j] && result[j][k]);
      |                     ~~^~~~~~~~~~
ltrominoes.cpp:55:58: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) for (int k = 0; k < b[0].size(); k++) result[i][k] = result[i][k] || (result[i][j] && result[j][k]);
      |                                                        ~~^~~~~~~~~~
ltrominoes.cpp:55:93: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < a.size(); i++) for (int j = 0; j < b.size(); j++) for (int k = 0; k < b[0].size(); k++) result[i][k] = result[i][k] || (result[i][j] && result[j][k]);
      |                                                                                           ~~^~~~~~~~~~~~~
ltrominoes.cpp: In function 'std::vector<std::vector<bool> > matexp(std::vector<std::vector<bool> >, int64_t)':
ltrominoes.cpp:63:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (int i = 0; i < a.size(); i++) for (int j = 0; j < a.size(); j++) result[i][j] = i == j;
      |                         ~~^~~~~~~~~~
ltrominoes.cpp:63:62: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (int i = 0; i < a.size(); i++) for (int j = 0; j < a.size(); j++) result[i][j] = i == j;
      |                                                            ~~^~~~~~~~~~
ltrominoes.cpp:63:99: error: no match for 'operator=' (operand types are 'std::vector<std::vector<bool> >' and 'bool')
   63 |         for (int i = 0; i < a.size(); i++) for (int j = 0; j < a.size(); j++) result[i][j] = i == j;
      |                                                                                                   ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from ltrominoes.cpp:15:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<std::vector<bool> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from ltrominoes.cpp:15:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<std::vector<bool> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<std::vector<bool> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ltrominoes.cpp:64:16: error: could not convert 'result' from 'std::vector<std::vector<bool> > [(<anonymous> + 1)][(<anonymous> + 1)]' to 'std::vector<std::vector<bool> >'
   64 |         return result;
      |                ^~~~~~
      |                |
      |                std::vector<std::vector<bool> > [(<anonymous> + 1)][(<anonymous> + 1)]
ltrominoes.cpp:66:12: error: incompatible types in assignment of 'std::vector<std::vector<bool> >' to 'std::vector<std::vector<bool> > [(<anonymous> + 1)][(<anonymous> + 1)]'
   66 |     result = matexp(matmul(a, a), k / 2);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ltrominoes.cpp:67:37: error: could not convert '(std::vector<std::vector<bool> > (*)[(<anonymous> + 1)])(& result)' from 'std::vector<std::vector<bool> > (*)[(<anonymous> + 1)]' to 'std::vector<std::vector<bool> >'
   67 |     if (k % 2 == 1) result = matmul(result, a);
      |                                     ^~~~~~
      |                                     |
      |                                     std::vector<std::vector<bool> > (*)[(<anonymous> + 1)]
ltrominoes.cpp:68:12: error: could not convert 'result' from 'std::vector<std::vector<bool> > [(<anonymous> + 1)][(<anonymous> + 1)]' to 'std::vector<std::vector<bool> >'
   68 |     return result;
      |            ^~~~~~
      |            |
      |            std::vector<std::vector<bool> > [(<anonymous> + 1)][(<anonymous> + 1)]
ltrominoes.cpp: In function 'int main()':
ltrominoes.cpp:78:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   78 |         return;
      |         ^~~~~~
ltrominoes.cpp:81:29: error: 'n' was not declared in this scope
   81 |     sort(blocked, blocked + n);
      |                             ^
ltrominoes.cpp:89:41: error: incompatible types in assignment of 'bool' to 'std::vector<std::vector<bool> > [(1 << w)]'
   89 |     for (int i = 0; i < w; i++) curr[i] = i == 0;
      |                                 ~~~~~~~~^~~~~~~~
ltrominoes.cpp:91:23: error: could not convert '(std::vector<std::vector<bool> > (*)[(1 << w)])(& curr)' from 'std::vector<std::vector<bool> > (*)[(1 << w)]' to 'std::vector<std::vector<bool> >'
   91 |         curr = matmul(curr, matexp(transition, blocked[currblock].second - 1 - currpos));
      |                       ^~~~
      |                       |
      |                       std::vector<std::vector<bool> > (*)[(1 << w)]
ltrominoes.cpp:95:30: error: no match for 'operator=' (operand types are 'std::vector<std::vector<bool> >' and 'int')
   95 |                 curr[0][i] = 0;
      |                              ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from ltrominoes.cpp:15:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<bool> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from ltrominoes.cpp:15:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::vector<bool> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<bool>; _Alloc = std::allocator<std::vector<bool> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<bool> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ltrominoes.cpp:99:19: error: could not convert '(std::vector<std::vector<bool> > (*)[(1 << w)])(& curr)' from 'std::vector<std::vector<bool> > (*)[(1 << w)]' to 'std::vector<std::vector<bool> >'
   99 |     curr = matmul(curr, matexp(transition, h - currpos));
      |                   ^~~~
      |                   |
      |                   std::vector<std::vector<bool> > (*)[(1 << w)]
ltrominoes.cpp:100:18: error: could not convert 'curr[0][0]' from 'std::vector<std::vector<bool> >' to 'bool'
  100 |     if (curr[0][0]) cout << "YES";
      |         ~~~~~~~~~^
      |                  |
      |                  std::vector<std::vector<bool> >