제출 #413689

#제출 시각아이디문제언어결과실행 시간메모리
413689LastRonin자리 배치 (IOI18_seats)C++14
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #include "seats.h" #define ll long long #define pb push_back #define si short int #define f first #define s second #define mp make_pair using namespace std; const ll N = 1e6 + 3; const ll big = 1e9; int n; int h, w; int ans = 0; vector<si> R, C; struct seg { si t[4 * N][2]; void upd(int p, si z, int v = 1, int tl = 1, int tr = n) { if(tl == tr) { t[v][0] = z; t[v][1] = z; return; } ll m = (tl + tr) >> 1ll; if(p <= m) upd(p, z, v * 2, tl, m); else upd(p, z, v * 2 + 1, m + 1, tr); t[v][0] = min(t[v * 2][0], t[v * 2 + 1][0]); t[v][1] = max(t[v * 2][1], t[v * 2 + 1][1]); } pair<si, si> get(int l, int r, int v = 1, int tl = 1, int tr = n) { if(l > tr || tl > r) return mp(30000, -30000); if(l <= tl && tr <= r) return mp(t[v][0], t[v][1]); ll m = (tl + tr) >> 1ll; pair<si, si> v1 = get(l, r, v * 2, tl, m); pair<si, si> v2 = get(l, r, v * 2 + 1, m + 1, tr); return mp(min(v1.f, v2.f), max(v1.s, v2.s)); } } rt[2]; void give_initial_chart(int H, int W, vector<int> r, vector<int> c) { R = r, C = c; n = H*W; for(int i = 1; i <= n; i++) { rt[0].upd(i, r[i - 1]); rt[1].upd(i, c[i - 1]); } } int swap_seats(int a, int b) { swap(R[a], R[b]), swap(C[a], C[b]); rt[0].upd(a + 1, R[a]), rt[0].upd(b + 1, R[b]); rt[1].upd(a + 1, C[a]), rt[1].upd(b + 1, C[b]); int ans = 0; for(int i = 1; i <= n;) { pair<si, si> x = rt[0].get(1, i); pair<si, si> y = rt[1].get(1, i); int k = (x.s - x.f + 1) * (y.s - y.f + 1) - i; if(k == 0) ans++, k = min(x.s - x.f + 1, y.s - y.f + 1); i += k; } return ans; } /* int main() { int n, m, q; cin >> n >> m >> q; vector<int> rr, cc; for(int i = 1, a, b; i <= n*m; i++) cin >> a >> b, rr.pb(a), cc.pb(b); give_initial_chart(n, m, rr, cc); while(q--) { ll a, b; cin >> a >> b; cout << swap_seats(a, b) << "\n"; } } */

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

seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:48:6: error: no match for 'operator=' (operand types are 'std::vector<short int>' and 'std::vector<int>')
   48 |  R = r, C = c;
      |      ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from seats.cpp:2:
/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 = short int; _Alloc = std::allocator<short int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<short int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from seats.cpp:2:
/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 = short int; _Alloc = std::allocator<short int>]'
  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 'std::vector<int>' to 'std::vector<short int>&&'
  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 = short int; _Alloc = std::allocator<short int>]'
  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 'std::vector<int>' to 'std::initializer_list<short int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
seats.cpp:48:13: error: no match for 'operator=' (operand types are 'std::vector<short int>' and 'std::vector<int>')
   48 |  R = r, C = c;
      |             ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from seats.cpp:2:
/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 = short int; _Alloc = std::allocator<short int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<short int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from seats.cpp:2:
/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 = short int; _Alloc = std::allocator<short int>]'
  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 'std::vector<int>' to 'std::vector<short int>&&'
  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 = short int; _Alloc = std::allocator<short int>]'
  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 'std::vector<int>' to 'std::initializer_list<short int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~