Submission #413761

#TimeUsernameProblemLanguageResultExecution timeMemory
413761LastRonin자리 배치 (IOI18_seats)C++14
Compilation error
0 ms0 KiB
#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 = 1<<20; const ll big = 1e9; int n, dl; int h, w; int ans = 0; vector<int> R, C; struct segsnizu { si t[2 * N], t2[2 * N], t3[2 * N], t4[2 * N]; void upd(int p, si z, si z2) { int v = dl + p - 1; t[v] = t2[v] = z; t3[v] = t4[v] = z2; v >>= 1; while(v) { t4[v] = min(t4[v * 2], t4[v * 2 + 1]); t3[v] = max(t3[v * 2], t3[v * 2 + 1]); t2[v] = min(t2[v * 2], t2[v * 2 + 1]); t[v] = max(t[v * 2], t[v * 2 + 1]); v >>= 1; } } pair<int, si> get(int l, int r) { l = dl + l - 1, r = dl + r - 1; int ans = -30000, ans2 = 30000, ans3 = -30000, ans4 = 30000; while(l <= r) { if(l&1) { ans = max(t[l], ans); ans2 = min(t2[l], ans2); ans3 = max(t3[l], ans3); ans4 = min(t4[l++], ans4); } if(!(r&1)) { ans = max(t[r], ans); ans2 = min(t2[r], ans2); ans3 = max(t3[r], ans3); ans4 = min(t4[r--], ans4); } l >>= 1, r >>= 1; } return mp((ans - ans2 + 1) * (ans3 - ans4 + 1), min(ans - ans2 + 1, ans3 - ans4 + 1)); } } rt; void give_initial_chart(int H, int W, vector<int> r, vector<int> c) { R = r, C = c; n = H*W; dl = (1<<(__lg(n - 1) + 1)); for(int i = 1; i <= n; i++) { rt.upd(i, r[i - 1], c[i - 1]); } } int swap_seats(int a, int b) { swap(R[a], R[b]), swap(C[a], C[b]); rt.upd(a + 1, R[a], C[a]), rt.upd(b + 1, R[b], C[b]); int ans = 0; for(int i = 1; i <= n;) { pair<int, si> v = rt.get(1, i); v.f -= i; if(v.f == 0) ans++, v.f = v.s; i += v.f; } 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"; } } */

Compilation message (stderr)

seats.cpp: In member function 'std::pair<int, short int> segsnizu::get(int, int)':
seats.cpp:39:24: error: no matching function for call to 'max(short int&, int&)'
   39 |     ans = max(t[l], ans);
      |                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
seats.cpp:39:24: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   39 |     ans = max(t[l], ans);
      |                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
seats.cpp:39:24: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   39 |     ans = max(t[l], ans);
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
seats.cpp:39:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   39 |     ans = max(t[l], ans);
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
seats.cpp:39:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   39 |     ans = max(t[l], ans);
      |                        ^
seats.cpp:40:27: error: no matching function for call to 'min(short int&, int&)'
   40 |     ans2 = min(t2[l], ans2);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
seats.cpp:40:27: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   40 |     ans2 = min(t2[l], ans2);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
seats.cpp:40:27: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   40 |     ans2 = min(t2[l], ans2);
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
seats.cpp:40:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   40 |     ans2 = min(t2[l], ans2);
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
seats.cpp:40:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   40 |     ans2 = min(t2[l], ans2);
      |                           ^
seats.cpp:41:27: error: no matching function for call to 'max(short int&, int&)'
   41 |     ans3 = max(t3[l], ans3);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
seats.cpp:41:27: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   41 |     ans3 = max(t3[l], ans3);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
seats.cpp:41:27: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   41 |     ans3 = max(t3[l], ans3);
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
seats.cpp:41:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   41 |     ans3 = max(t3[l], ans3);
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
seats.cpp:41:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   41 |     ans3 = max(t3[l], ans3);
      |                           ^
seats.cpp:42:29: error: no matching function for call to 'min(short int&, int&)'
   42 |     ans4 = min(t4[l++], ans4);
      |                             ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
seats.cpp:42:29: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   42 |     ans4 = min(t4[l++], ans4);
      |                             ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
seats.cpp:42:29: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   42 |     ans4 = min(t4[l++], ans4);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
seats.cpp:42:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   42 |     ans4 = min(t4[l++], ans4);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
seats.cpp:42:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   42 |     ans4 = min(t4[l++], ans4);
      |                             ^
seats.cpp:45:24: error: no matching function for call to 'max(short int&, int&)'
   45 |     ans = max(t[r], ans);
      |                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
seats.cpp:45:24: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   45 |     ans = max(t[r], ans);
      |                        ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
seats.cpp:45:24: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   45 |     ans = max(t[r], ans);
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
seats.cpp:45:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   45 |     ans = max(t[r], ans);
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
seats.cpp:45:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   45 |     ans = max(t[r], ans);
      |                        ^
seats.cpp:46:27: error: no matching function for call to 'min(short int&, int&)'
   46 |     ans2 = min(t2[r], ans2);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
seats.cpp:46:27: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   46 |     ans2 = min(t2[r], ans2);
      |                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from seats.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const