Submission #559621

#TimeUsernameProblemLanguageResultExecution timeMemory
559621slimeTable Tennis (info1cup20_tabletennis)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;
#ifdef ONLINE_JUDGE
const int MAXN = 2e5 + 10;
#endif
#ifndef ONLINE_JUDGE
const int MAXN = 1029;
#endif
const int MOD = 1e9 + 7;
#define ll __int128
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
ll read() { int x; cin >> x; return (ll)x; }
long long bm(long long b, long long p) {
  if(p==0) return 1 % MOD;
  long long r = bm(b, p >> 1);
  if(p&1) return (((r*r) % MOD) * b) % MOD;
  return (r*r) % MOD;
}
long long inv(long long b) { 
  return bm(b, MOD-2);
}
long long f[MAXN];
long long nCr(int n, int r) { 
  long long ans = f[n]; ans *= inv(f[r]); ans %= MOD;
  ans *= inv(f[n-r]); ans %= MOD; return ans;
}
void precomp() { for(int i=0; i<MAXN; i++) f[i] = (i == 0 ? 1 % MOD : (f[i-1] * i) % MOD); }
int fastlog(int x) {
  return (x == 0 ? -1 : 32 - __builtin_clz(x) - 1);
}
void gay(int i) { cout << "Case #" << i << ": "; }
void solve(int tc) {
  int n, k; cin >> n >> k;
  int a[n+k+1];
  for(int i=1; i<=n+k; i++) cin >> a[i];
  unordered_map<int32_t, bool> yes;
  for(int i=1; i<=n+k; i++) yes[a[i]] = 1;
  vector<int> sums;
  for(int i=max(2ll, n); i<=n+k; i++) {
    for(int j=1; j<=k+1; j++) {
      if(j < i) sums.push_back(a[i] + a[j]);
    }
  }
  for(int x: sums) {
    int ct = 0;
    for(int i=1; i<=n+k; i++) {
      if(a[i] * 2 == x) continue;
      else if(yes[x - a[i]]) ct++;
    }
    if(ct >= n) {
      vector<int> v;
      int e = 0;
      for(int i=1; i<=n+k; i++) {
        if(a[i] * 2 == x) continue;
        if(yes[x - a[i]]) {
          v.push_back(a[i]);
          v.push_back(x - a[i]);
          e++;
          if(e == n/2) break;
        }
      }
      sort(v.begin(), v.end());
      for(int x: v) cout << x << " ";
      cout << "\n";
      return;
    }
  }
}
int32_t main() {
  precomp();
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
} 
// I don't know geometry. 


// n = 13, k = 3: 0000001010000
// n = 13, k = 5: 0000010001000
// n = 13, k = 7: 0001000100010

// if k < n/2 and n odd: 1[010...10]111...1

Compilation message (stderr)

tabletennis.cpp: In function 'void solve(int)':
tabletennis.cpp:42:23: error: no matching function for call to 'max(long long int, int&)'
   42 |   for(int i=max(2ll, n); i<=n+k; i++) {
      |                       ^
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 tabletennis.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:
tabletennis.cpp:42:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |   for(int i=max(2ll, n); i<=n+k; i++) {
      |                       ^
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 tabletennis.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:
tabletennis.cpp:42:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   42 |   for(int i=max(2ll, n); i<=n+k; i++) {
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tabletennis.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:
tabletennis.cpp:42:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |   for(int i=max(2ll, n); i<=n+k; i++) {
      |                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tabletennis.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:
tabletennis.cpp:42:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   42 |   for(int i=max(2ll, n); i<=n+k; i++) {
      |                       ^