이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |