제출 #638658

#제출 시각아이디문제언어결과실행 시간메모리
638658Dec0DeddTable Tennis (info1cup20_tabletennis)C++14
34 / 100
909 ms311040 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; const int N = 2e5+10; const int K = 50; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int a, int b){ return a+rng()%(b-a+1); } int a[N], n, k, sz; gp_hash_table<int, int> cnt; gp_hash_table<int, bool> m; void add(int i) { for (int j=1; j<=sz; ++j) { if (j != i) ++cnt[a[i]+a[j]]; } } int num(int s) { int res=0; for (int i=1; i<=sz; ++i) { if (2*a[i] == s || m.find(s-a[i]) == m.end()) continue; ++res; } return res; } vector<int> gen(int s) { vector<int> res; for (int i=1; i<=sz; ++i) { if (2*a[i] == s || m.find(s-a[i]) == m.end()) continue; res.push_back(a[i]); } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n>>k; sz=n+k; for (int i=1; i<=sz; ++i) cin>>a[i]; for (int i=1; i<=sz; ++i) m[a[i]]=true; vector<int> r; for (int i=1; i<=n; ++i) r.push_back(i); shuffle(r.begin(), r.end(), rng); for (int i=0; i<min(sz, K); ++i) add(r[i]); vector<int> tmp; for (auto u : cnt) { if (u.second >= K-15) tmp.push_back(u.first); } vector<int> x; for (auto u : tmp) { if (num(u) >= n) { x=gen(u); break; } } assert((int)x.size() >= n); for (auto u : x) cout<<u<<" "; cout<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...