This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define bug(x) cerr << #x << ": " << x << endl
using namespace std;
using ll = long long;
const int MAX = 15e4 + 10;
int n, v[MAX], sum, k;
map<int, int> m;
bool fake[MAX];
void sol1(){
int qtd = 0, err = 0;
sum = v[1] + v[n + k];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd == 1) err = i;
}
}
if(qtd == 1){
for(int i = 1; i <= n + k; i++){
if(i != err){
printf("%d ", v[i]);
}
}
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
qtd = 0, err = 0;
sum = v[2] + v[n + k];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd == 1) err = i;
}
}
if(qtd == 1){
for(int i = 1; i <= n + k; i++){
if(i != err){
printf("%d ", v[i]);
}
}
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
qtd = 0, err = 0;
sum = v[1] + v[n + k - 1];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd == 1) err = i;
}
}
if(qtd == 1){
for(int i = 1; i <= n + k; i++){
if(i != err){
printf("%d ", v[i]);
}
}
}
}
void sol2(){
//1 e n + k
int qtd = 0;
vector<int> err;
sum = v[2] + v[n + k - 1];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
//1 e n + k - 1
qtd = 0;
sum = v[2] + v[n + k];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
//1 e 2
qtd = 0;
sum = v[3] + v[n + k];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
//2 e n + k - 1
qtd = 0;
sum = v[1] + v[n + k];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
//2 e n + k
qtd = 0;
sum = v[1] + v[n + k - 1];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
//n + k - 1 e n + k
qtd = 0;
sum = v[1] + v[n + k - 2];
for(int i = 1; i <= n + k; i++){
if(m[sum - v[i]] != 0){
m[sum - v[i]]--;
}
else{
qtd++;
if(qtd <= 2) err.pb(i);
}
}
if(qtd == 2){
for(int i = 1; i <= n + k; i++){
if(i != err[0] && i != err[1]){
printf("%d ", v[i]);
}
}
return;
}
for(int i = 1; i <= n + k; i++){
m[v[i]]++;
}
err.clear();
}
int main(){
scanf("%d %d", &n, &k);
for(int i = 1; i <= n + k; i++){
scanf("%d", &v[i]);
m[v[i]]++;
}
if(k == 1) sol1();
if(k == 2) sol2();
}
Compilation message (stderr)
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:276:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
276 | scanf("%d %d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~
tabletennis.cpp:279:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
279 | scanf("%d", &v[i]);
| ~~~~~^~~~~~~~~~~~~
# | 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... |