답안 #910989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910989 2024-01-18T10:44:44 Z Ianis Table Tennis (info1cup20_tabletennis) C++17
0 / 100
3000 ms 1372 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;

#define int int64_t

using pii = pair<int, int>;

const int NMAX = 2e5+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));

   if (sz(a) / 2 % 2 == 0) {
      for (int i = 0; i < sz(a) / 2; i++)
         a[i] += a[sz(a) - i - 1];
      a.resize(sz(a) / 2);
   } else {
      for (int i = 0; i < sz(a) / 2 - 1; i++)
         a[i] += a[sz(a) - i - 1];
      a.resize(sz(a) / 2 + 1);
   }

   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 << ' ';
   }
   cout << endl;
}

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

   read();
   solve();
   
   return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output does not have symmetry property
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3029 ms 1076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 1372 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3037 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3028 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -