Submission #532456

#TimeUsernameProblemLanguageResultExecution timeMemory
532456definitelynotmeeTeams (CEOI11_tea)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const int MAXN = 1e6+1; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> v(n); for(int i = 0; i < n; i++) cin >> v[i]; vector<int> o(n); iota(all(o),0); sort(all(o),[&](int a, int b){ return v[a] > v[b]; }); matrix<int> resp; int start = 0; while(start < n){ while(start < n && n-start>=v[o[start]]){ resp.push_back({}); for(int i = 0; i < v[o[start]]; i++){ resp.back().push_back(o[i+start]); } start+=v[o[start]]; }; while(start < n && n-start<v[o[start]]){ int ptr = lower_bound(all(resp),resp.back(),[&](vector<int>&a, vector<int>&b){ return a.size() > b.size(); })-resp.begin(); while(start < n && n-start<v[o[start]] && ptr < resp.size()){ resp[ptr].push_back(o[start]); ptr++; start++; } } } if(start < n){ resp.push_back({}); while(start < n) resp.back().push_back(o[start]), start++; } cout << resp.size() << '\n'; int tot =0; for(vector<int>& i : resp){ tot+=i.size(); } for(vector<int>& i : resp){ cout << i.size() << ' '; for(int j : i){ cout << j+1 << ' '; } cout << '\n'; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:55:59: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             while(start < n && n-start<v[o[start]] && ptr < resp.size()){
      |                                                       ~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 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 tea.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; _Value = const std::vector<int>; _Compare = main()::<lambda(std::vector<int>&, std::vector<int>&)>]':
/usr/include/c++/10/bits/stl_algobase.h:1324:14:   required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; _Tp = std::vector<int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(std::vector<int>&, std::vector<int>&)> >]'
/usr/include/c++/10/bits/stl_algo.h:2041:32:   required from '_FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare) [with _FIter = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int>, std::allocator<std::vector<int> > > >; _Tp = std::vector<int>; _Compare = main()::<lambda(std::vector<int>&, std::vector<int>&)>]'
tea.cpp:54:14:   required from here
/usr/include/c++/10/bits/predefined_ops.h:194:23: error: no match for call to '(main()::<lambda(std::vector<int>&, std::vector<int>&)>) (std::vector<int>&, const std::vector<int>&)'
  194 |  { return bool(_M_comp(*__it, __val)); }
      |                ~~~~~~~^~~~~~~~~~~~~~
tea.cpp:52:57: note: candidate: 'main()::<lambda(std::vector<int>&, std::vector<int>&)>' (near match)
   52 |             int ptr = lower_bound(all(resp),resp.back(),[&](vector<int>&a, vector<int>&b){
      |                                                         ^
tea.cpp:52:57: note:   conversion of argument 2 would be ill-formed:
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 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 tea.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h:194:23: error: binding reference of type 'std::vector<int>&' to 'const std::vector<int>' discards qualifiers
  194 |  { return bool(_M_comp(*__it, __val)); }
      |                ~~~~~~~^~~~~~~~~~~~~~