Submission #421171

#TimeUsernameProblemLanguageResultExecution timeMemory
421171A_DSeats (IOI18_seats)C++14
Compilation error
0 ms0 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; const int N=1e6+100; struct node{ int mnx; int mny; int mxx; int mxy; }; node INF; int n; node seg[4*N]; inline node com(node&a,node&b) { node ret; ret.mnx=min(a.mnx,b.mnx); ret.mny=min(a.mny,b.mny); ret.mxx=max(a.mxx,b.mxx); ret.mxy=max(a.mxy,b.mxy); return ret; } void update(int p,int s,int e,int&i,int&x,int&y) { if(s==e){ seg[p].mnx=x; seg[p].mxx=x; seg[p].mny=y; seg[p].mxy=y; return; } int mid=(s+e)/2; if(i<=mid){ update(p*2,s,mid,i,x,y); } else{ update(p*2+1,mid+1,e,i,x,y); } seg[p]=com(seg[p*2],seg[p*2+1]); } void fix(node u) { cout<<u.mnx<<" "<<u.mxx<<endl; cout<<u.mny<<" "<<u.mxy<<endl; } node get(int p,int s,int e,int&a,int&b) { // cout<<"\n"; //cout<<s<<" "<<e<<endl; // fix(seg[p]); // cout<<"\n"; if(a<=s&&e<=b)return seg[p]; if(s>b||e<a)return INF; int mid=(s+e)/2; return com( get(p*2 ,s ,mid,a,b), get(p*2+1,mid+1,e ,a,b) ); } void give_initial_chart(int H,int W,vector<int>R,vector<int>C){ INF.mnx=1e7; INF.mny=1e7; INF.mxx=-1e7; INF.mxy=-1e7; n=H*W; for(int i=0;i<n;i++){ update(1,0,n-1,i,R[i],C[i]); } } int swap_seats(int a, int b){ // cout<<"\n"; // cout<<"\n"; node aa=get(1,0,n-1,a,a); node bb=get(1,0,n-1,b,b); update(1,0,n-1,a,bb.mnx,bb.mny); update(1,0,n-1,b,aa.mnx,aa.mny); int i=0,ret=0; while(i<n){ node u=get(1,0,n-1,0,i); int k=(u.mxx-u.mnx+1)*(u.mxy-u.mny+1); //fix(u); if(k==i+1){ ret++; i++; } else{ i=k-1; } } return ret; }

Compilation message (stderr)

seats.cpp: In function 'node get(int, int, int, int&, int&)':
seats.cpp:56:20: error: cannot bind non-const lvalue reference of type 'node&' to an rvalue of type 'node'
   56 |                 get(p*2  ,s    ,mid,a,b),
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~
seats.cpp:14:22: note:   initializing argument 1 of 'node com(node&, node&)'
   14 | inline node com(node&a,node&b)
      |                 ~~~~~^
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:81:31: error: no matching function for call to 'get(int, int, int, int, int&)'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
seats.cpp:46:6: note: candidate: 'node get(int, int, int, int&, int&)' (near match)
   46 | node get(int p,int s,int e,int&a,int&b)
      |      ^~~
seats.cpp:46:6: note:   conversion of argument 4 would be ill-formed:
seats.cpp:81:28: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                            ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:223: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>&)'
  223 |     get(std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:223:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:228: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>&&)'
  228 |     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:228:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:233: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>&)'
  233 |     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:233:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:238: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>&&)'
  238 |     get(const std::pair<_Tp1, _Tp2>&& __in) noexcept
      |     ^~~
/usr/include/c++/10/utility:238:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:247:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)'
  247 |     get(pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:247:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:252:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)'
  252 |     get(const pair<_Tp, _Up>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:252:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:257:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)'
  257 |     get(pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:257:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_T1, _T2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:262:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_T1, _T2>&&)'
  262 |     get(const pair<_Tp, _Up>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:262:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:267:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)'
  267 |     get(pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:267:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:272:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)'
  272 |     get(const pair<_Up, _Tp>& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:272:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:277:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)'
  277 |     get(pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:277:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::pair<_Up, _Tp>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from seats.cpp:2:
/usr/include/c++/10/utility:282:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const std::pair<_Up, _Tp>&&)'
  282 |     get(const pair<_Up, _Tp>&& __p) noexcept
      |     ^~~
/usr/include/c++/10/utility:282:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::pair<_Up, _Tp>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/array:334:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(std::array<_Tp, _Nm>&)'
  334 |     get(array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:334:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/array:343:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(std::array<_Tp, _Nm>&&)'
  343 |     get(array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:343:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::array<_Tp, _Nm>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/array:351:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const std::array<_Tp, _Nm>&)'
  351 |     get(const array<_Tp, _Nm>& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:351:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/array:360:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const std::array<_Tp, _Nm>&&)'
  360 |     get(const array<_Tp, _Nm>&& __arr) noexcept
      |     ^~~
/usr/include/c++/10/array:360:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::array<_Tp, _Nm>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1294:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(std::tuple<_Elements ...>&)'
 1294 |     get(tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1294:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1300: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 ...>&)'
 1300 |     get(const tuple<_Elements...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1300:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1306:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&)'
 1306 |     get(tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1306:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1315: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 ...>&&)'
 1315 |     get(const tuple<_Elements...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1315:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1338:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(std::tuple<_Elements ...>&)'
 1338 |     get(tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1338:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1344:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(std::tuple<_Elements ...>&&)'
 1344 |     get(tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1344:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1350:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const std::tuple<_Elements ...>&)'
 1350 |     get(const tuple<_Types...>& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1350:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:71,
                 from seats.cpp:2:
/usr/include/c++/10/tuple:1357:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const std::tuple<_Elements ...>&&)'
 1357 |     get(const tuple<_Types...>&& __t) noexcept
      |     ^~~
/usr/include/c++/10/tuple:1357:5: note:   template argument deduction/substitution failed:
seats.cpp:81:31: note:   mismatched types 'const std::tuple<_Elements ...>' and 'int'
   81 |         node u=get(1,0,n-1,0,i);
      |                               ^