Submission #910975

# Submission time Handle Problem Language Result Execution time Memory
910975 2024-01-18T10:29:23 Z vjudge1 Table Tennis (info1cup20_tabletennis) C++17
0 / 100
3000 ms 1048576 KB
#include <algorithm>
#include <iostream>
#include <fstream>
#include <queue>
#include <cmath>

#define fi first
#define se second

#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()

using namespace std;

using pii = pair<int, int>;

const int NMAX = 15e4+5;

int n, k;
int a[NMAX];
vector<int> ans;

void read() {
   cin >> n >> k;
   for (int i = 1; i <= n + k; i++) {
      cin >> a[i];
   }
}

bool check(vector<int> a) {
   if (sz(a) == 2) return a[0] == a[1];
   sort(all(a));
   for (int i = 0; i < sz(a) / 2; i++)
      a[i] += a[sz(a) - i - 1];

   if (sz(a) % 2 == 0) a.resize(sz(a) / 2);
   else a.resize(sz(a) / 2 + 2);

   return check(a);
}

void solve() {
   if (k == 1) {
      vector<int> v;
      for (int i = 1; i <= n; i++)
         v.push_back(a[i]);
      for (int i = 0; i < n; i++) {
         if (i != n - 1)
            swap(v[i], v[n - 1]);
         if (check(v)) {
            ans = v;
            break;
         }
         if (i != n - 1)
            swap(v[i], v[n - 1]);
      }
   } else {
      for (int mask = 1; mask < 1 << (n + k); mask++) {
         if (__builtin_popcount(mask) != n) continue;
         vector<int> v;
         for (int i = 0; i < n + k; i++) {
            if (mask & (1 << i))
               v.push_back(a[i + 1]);
         }
         if (check(v)) {
            ans = v;
            break;
         }
      }
   }
   sort(all(ans));
   for (auto &it : ans) {
      cout << it << ' ';
   }
}

signed main() {
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif

   read();
   solve();
   
   return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 600 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 856 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 504 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Runtime error 1356 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Incorrect 2 ms 352 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Execution timed out 3004 ms 2440 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -