제출 #122309

#제출 시각아이디문제언어결과실행 시간메모리
122309nvmdava자리 배치 (IOI18_seats)C++17
컴파일 에러
0 ms0 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; vector<int> r, c; vector<vector<int> > s; int cnt[2097152], mn[2097152], lz[2097152]; int L, R, val; void push(int id, int l, int r){ mn[id] += lz[id]; if(l != r){ lz[id << 1] += lz[id]; lz[id << 1 | 1] += lz[id]; } lz[id] = 0; } void update(int id, int l, int r){ push(id, l, r); if(l > R || r < L) return; if(l >= L && r <= R){ lz[id] += val; push(id, l, r); return; } int m = (l + r) >> 1; update(id << 1, l, m); update(id << 1 | 1, m + 1, r); if(mn[id << 1] < mn[id << 1 | 1]){ mn[id] = mn[id << 1]; cnt[id] = cnt[id << 1]; } else if(mn[id << 1] > mn[id << 1 | 1]){ mn[id] = mn[id << 1 | 1]; cnt[id] = cnt[id << 1 | 1]; } else { mn[id] = mn[id << 1]; cnt[id] = cnt[id << 1] + cnt[id << 1 | 1]; } } void build(int id, int l, int r){ if(l == r){ cnt[id] = 1; return; } int m = (l + r) >> 1; build(id << 1, l, m); build(id << 1 | 1, m + 1, r); cnt[id] = cnt[id << 1] + cnt[id << 1 | 1]; } vector<int> ord; void order(int a, int b, int c, int d){ ord = {a, b, c, d}; sort(t.begin(), t.end()); } int n; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { n = H * W; for(int i = 0; i <= H + 1; i++){ s.push_back(vector<int>(W + 2, n + 1)); } r.push_back(0); c.push_back(0); build(1, 1, n); for(int i = 0; i < n; i++){ s[R[i] + 1][C[i] + 1] = i + 1; c.push_back(C[i] + 1); r.push_back(R[i] + 1); } val = 1; for(int i = 0; i <= H; i++){ for(int j = 0; j <= W; j++){ order(s[i][j], s[i + 1][j], s[i][j + 1], s[i + 1][j + 1]); L = ord[0]; ::R = ord[1] - 1; if(L <= ::R)update(1, 1, n); L = ord[2]; ::R = ord[3] - 1; if(L <= ::R)update(1, 1, n); } } } int dx[] = {1, -1, 1, -1}; int dy[] = {1, 1, -1, -1}; int swap_s(int a, int b){ a++; b++; val = -1; int t[] = {a, b}; for(int j = 0; j < 2; j++){ int x = r[t[j]], y = c[t[j]]; for(int i = 0; i < 4; i++){ order(s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]); L = ord[0]; R = ord[1] - 1; if(L <= R) update(1, 1, n); L = ord[2]; R = ord[3] - 1; if(L <= R) update(1, 1, n); } } swap(r[a], r[b]); swap(c[a], c[b]); swap(s[r[a]][c[a]], s[r[b]][c[b]]); val = 1; for(int j = 0; j < 2; j++){ int x = r[t[j]], y = c[t[j]]; for(int i = 0; i < 4; i++){ L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]); R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1; if(L <= R) update(1, 1, n); L = get(3, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]); R = get(4, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1; if(L <= R) update(1, 1, n); } } return cnt[1]; }

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

seats.cpp: In function 'void order(int, int, int, int)':
seats.cpp:54:7: error: 't' was not declared in this scope
  sort(t.begin(), t.end());
       ^
seats.cpp: In function 'int swap_s(int, int)':
seats.cpp:113:81: error: no matching function for call to 'get(int, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&)'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:229:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:229:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:234:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/7/utility:234:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:239:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:239:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:248:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:248:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:253:5: note: candidate: template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)
     get(const pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:253:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:258:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)
     get(pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:258:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:263:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)
     get(pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:263:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:268:5: note: candidate: template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)
     get(const pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:268:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:273:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)
     get(pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:273:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/tuple:39:0,
                 from /usr/include/c++/7/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/array:307:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)
     get(array<_Tp, _Nm>& __arr) noexcept
     ^~~
/usr/include/c++/7/array:307:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/tuple:39:0,
                 from /usr/include/c++/7/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/array:316:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)
     get(array<_Tp, _Nm>&& __arr) noexcept
     ^~~
/usr/include/c++/7/array:316:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/tuple:39:0,
                 from /usr/include/c++/7/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/array:324:5: note: candidate: template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)
     get(const array<_Tp, _Nm>& __arr) noexcept
     ^~~
/usr/include/c++/7/array:324:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1314:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)
     get(tuple<_Elements...>& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1314:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1320:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const std::tuple<_Elements ...>&)
     get(const tuple<_Elements...>& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1320:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1326:5: note: candidate: template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)
     get(tuple<_Elements...>&& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1326:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1349:5: note: candidate: template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)
     get(tuple<_Types...>& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1349:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1355:5: note: candidate: template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)
     get(tuple<_Types...>&& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1355:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
In file included from /usr/include/c++/7/functional:54:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/7/tuple:1361:5: note: candidate: template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)
     get(const tuple<_Types...>& __t) noexcept
     ^~~
/usr/include/c++/7/tuple:1361:5: note:   template argument deduction/substitution failed:
seats.cpp:113:81: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
    L = get(1, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]);
                                                                                 ^
seats.cpp:114:81: error: no matching function for call to 'get(int, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int> >::value_type&)'
    R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1;
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:229:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:229:5: note:   template argument deduction/substitution failed:
seats.cpp:114:81: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
    R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1;
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:234:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/7/utility:234:5: note:   template argument deduction/substitution failed:
seats.cpp:114:81: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
    R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1;
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:239:5: note: candidate: template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:239:5: note:   template argument deduction/substitution failed:
seats.cpp:114:81: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
    R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1;
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:248:5: note: candidate: template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:248:5: note:   template argument deduction/substitution failed:
seats.cpp:114:81: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
    R = get(2, s[x][y], s[x + dx[i]][y], s[x][y + dy[i]], s[x + dx[i]][y + dy[i]]) - 1;
                                                                                 ^
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from seats.h:3,
                 from seats.cpp:1:
/usr/include/c++/7/utility:253:5: note: candidate: template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::p