# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
717430 | 2023-04-01T22:48:25 Z | vjudge1 | Table Tennis (info1cup20_tabletennis) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define int long long const int mxN = 2e5 + 7; const long long rand_max = 1e18; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long x_rand(long long i) { return uniform_int_distribution<long long>(0, rand_max)(rng) % i; } int arr[mxN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); auto rand = [&](long long a, long long b) { return a + x_rand(rand_max) % (b - a + 1); }; int n, k; cin >> n >> k; bitset<2000000001> in, bad; for (int i = 0; i < n + k; ++i) { cin >> arr[i]; in[arr[i]] = true; } while (true) { int sum = arr[rand(0, k + 1)] + arr[rand(n - 1, n + k - 1)]; if (bad[sum]) { ++cnt; continue; } vector<int> nums; for (int l = 0; l < n + k; ++l) { if (sum - arr[l] >= 0 && in[sum - arr[l]]) { nums.push_back(arr[l]); } } if (nums.size() >= n) { for (int l = 0; l < n; ++l) { cout << nums[l] << ' '; } cout << "\n"; exit(0); } bad[sum] = true; } assert(false); } // 1 2 1 2 3