Submission #863779

#TimeUsernameProblemLanguageResultExecution timeMemory
863779Trisanu_DasOlympiads (BOI19_olympiads)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") int n, m, k, sMin, sMax; vector<pair<int, vector<int> > > C; multiset<int> S; bool f(int t, int j, int s, vector<int> x){ int xx, sNew, sNewMax; vector<int> xNew; if (t == 0) { S.insert(s); if (S.size() > c) { S.erase(S.begin()); sMin = *S.begin(); if (sMin == sMax) return true; } } else { for (int i = j; i < n; i++) { sNewMax = 0; sNew = 0; mNew = vector<int>(k); for (int l = 0; l < k; l++) { x = max(x[l], C[i].second[l]); sNew += xx; xNew[l] = xx; sNewMax += max(xx, C[i].first); } if (sNewMax < sMin) return false; if (f(t - 1, i + 1, sNew, xNew)) return true; } } return false; } int main() { ios_base::sync_with_stdio(false); int x, xMax; vector<int> M; cin >> n >> k >> c; C = vector<pair<int, vector<int> > >(n, {0, vector<int>(k)}); M = vector<int>(k); for (int i = 0; i < n; i++) { xMax = 0; for (int j = 0; j < k; j++) { cin >> x; C[i].second[j] = x; xMax = max(xMax, x); M[j] = max(M[j], x); } C[i].first = xMax; } sort(C.begin(), C.end(), greater<pair<int, vi>>()); sMin = 0; sMax = 0; for (int i = 0; i < k; i++) sMax += M[i]; f(k, 0, 0, vi(k)); cout << sMin << '\n'; }

Compilation message (stderr)

olympiads.cpp: In function 'bool f(int, int, int, std::vector<int>)':
olympiads.cpp:15:24: error: 'c' was not declared in this scope
   15 |         if (S.size() > c) {
      |                        ^
olympiads.cpp:25:13: error: 'mNew' was not declared in this scope; did you mean 'xNew'?
   25 |             mNew = vector<int>(k);
      |             ^~~~
      |             xNew
olympiads.cpp:27:45: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'const int')
   27 |                 x = max(x[l], C[i].second[l]);
      |                                             ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from olympiads.cpp:1:
/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 = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'const int' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from olympiads.cpp:1:
/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 = int; _Alloc = std::allocator<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 'const int' to 'std::vector<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 = int; _Alloc = std::allocator<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 'const int' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
olympiads.cpp: In function 'int main()':
olympiads.cpp:44:22: error: 'c' was not declared in this scope
   44 |     cin >> n >> k >> c;
      |                      ^
olympiads.cpp:57:48: error: 'vi' was not declared in this scope
   57 |     sort(C.begin(), C.end(), greater<pair<int, vi>>());
      |                                                ^~
olympiads.cpp:57:48: error: template argument 2 is invalid
olympiads.cpp:57:50: error: template argument 1 is invalid
   57 |     sort(C.begin(), C.end(), greater<pair<int, vi>>());
      |                                                  ^~