Submission #1317627

#TimeUsernameProblemLanguageResultExecution timeMemory
1317627JohanTable Tennis (info1cup20_tabletennis)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
const int B = 1e3 + 5;
signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int m = n + k;
  vector < int > a(m + 1);
  unordered_map < int , int > is;
  for(int i = 1; i <= m; i++){
    cin >> a[i];
    is[a[i]]++;
  }
  unoredered_set < int > st;
  unordered_map < int, int > mp;
  for(int i = 1; i <= min(m, k * 4); i++){  
    for(int j = i + 1; j <= m; j++){
      mp[a[i] + a[j]] += 2;
      st.insert(a[i] + a[j]);
    }
  }
  int mx = 0;
  vector < int > sums;
  for(auto x : st){
    if(mp[x] >= mx){
      if(mp[x] == mx)
        sums.push_back(x);
      else sums = {x};
      mx = mp[x];
    }
  }
  sort(sums.rbegin(), sums.rend());
  while(sums.size() > 100)sums.pop_back();
  for(auto sum : sums){
    deque < int > rs;
    for(int i = 1; i <= m; i++){
      if(is[sum - a[i]] > 0 && sum - a[i] != a[i] || is[sum - a[i]] > 1){
        rs.push_back(a[i]);
      }
    }
    if(rs.size() > n){
      rs.pop_front();
      rs.pop_back();
    }
    if(rs.size() == n){
      for(auto i : rs)
        cout << i << ' ';
      cout << endl;
      return 0;
    }
  }
}

Compilation message (stderr)

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:17:3: error: 'unoredered_set' was not declared in this scope
   17 |   unoredered_set < int > st;
      |   ^~~~~~~~~~~~~~
tabletennis.cpp:17:20: error: expected primary-expression before 'int'
   17 |   unoredered_set < int > st;
      |                    ^~~
tabletennis.cpp:22:7: error: 'st' was not declared in this scope; did you mean 'std'?
   22 |       st.insert(a[i] + a[j]);
      |       ^~
      |       std
tabletennis.cpp:27:16: error: 'st' was not declared in this scope; did you mean 'std'?
   27 |   for(auto x : st){
      |                ^~
      |                std
tabletennis.cpp:31:21: error: no match for 'operator=' (operand types are 'std::vector<int>' and '<brace-enclosed initializer list>')
   31 |       else sums = {x};
      |                     ^
In file included from /usr/include/c++/13/vector:72,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from tabletennis.cpp:1:
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/vector:66:
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~