/** made by amunduzbaev **/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vv vector
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef pair<int, pii> ipii;
typedef pair<pii, int> piii;
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
const int N = 2e5+5;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
#define MULTI 0
int n, m, k, ans, res, a[N];
/*
4 2
1 2 5 7 8 100
6 2
1 3 4 5 6 7 8 11
6 2
1 2 3 5 7 8 9 15
4 2
100 200 1 2 3 4
*/
bool check(int x, int b){
int l = 0, r = m-1;
while(l == x || l == b) l++;
while(r == x || r == b) r--;
int cur = a[l] + a[r];
//cout<<a[x]<<" "<<a[b]<<"\n";
for(int i=0;i<(n>>1);i++){
while(l == x || l == b) l++;
while(r == x || r == b) r--;
//cout<<a[l]<<" "<<a[r]<<"\n";
if(a[l] + a[r] != cur) return 0;
l++, r--;
}
return 1;
}
void print(int x, int b){
//cout<<x<<" "<<b<<"\n";
for(int i=0;i<m;i++){
if(i == x || i == b) continue;
cout<<a[i]<<" ";
}cout<<"\n";
}
void solve(int t_case){
cin>>n>>k;
m = n+k;
for(int i=0;i<n+k;i++) cin>>a[i];
sort(a, a+n+k);
//if(check(7, 4)) { print(4, 7); return; }
int pos = a[0] + a[m-1];
int bad1 = -1, bad2 = -1;
int l = 0, r = m-1;
for(int i=0;i<(n>>1);i++){
//cout<<a[l]<<" "<<a[r]<<" "<<pos<<"\n";
if(a[l] + a[r] != pos){
int res1 = -1, res2 = -1;
if(a[l] + a[r-1] == pos) res1 = r, r--;
else if(a[l+1] + a[r] == pos) res1 = l, l++;
else if(a[l] + a[r-2] == pos) res2 = r, res1 = r-1, r-=2;
else if(a[l+2] + a[r] == pos) res1 = l, res2 = l+1, l+=2;
else if(a[l+1] + a[r-1] == pos) res1 = l, res2 = r, l++, r--;
else break;
if(bad1 == -1){
if(res2 != -1) { bad1 = res1, bad2 = res2; break; }
else bad1 = res1;
}else { bad2 = res1; break; }
i--;
//cout<<i<<"\n";
}else l++, r--;
} //cout<<"\n";
if(bad1 == -1) bad1 = l;
if(bad2 == -1) bad2 = r;
if(check(bad1, bad2)) { print(bad1, bad2); return; }
bad2 = -1, bad1 = 0, pos = a[1] + a[m-1], l = 1, r = m-1;
for(int i=0;i<(n>>1);i++){
if(a[l] + a[r] != pos){
int res1 = -1;
if(a[l] + a[r-1] == pos) res1 = r, r--;
else if(a[l+1] + a[r] == pos) res1 = l, l++;
else { bad2 = res1; break; }
}else l++, r--;
}
if(bad2 == -1) bad2 = l;
if(check(bad1, bad2)) { print(bad1, bad2); return; }
bad2 = -1, bad1 = m-1, pos = a[0] + a[m-2], l = 0, r = m-2;
for(int i=0;i<(n>>1);i++){
//cout<<a[l]<<" "<<a[r]<<" "<<pos<<"\n";
if(a[l] + a[r] != pos){
int res1 = -1;
if(a[l] + a[r-1] == pos) res1 = r, r--;
else if(a[l+1] + a[r] == pos) res1 = l, l++;
else { bad2 = res1; break; }
}else l++, r--;
}
if(bad2 == -1) bad2 = l;
if(check(bad1, bad2)) { print(bad1, bad2); return; }
if(check(0, 1)){ print(0, 1); return; }
print(m-1, m-2);
}
signed main(){
NeedForSpeed
if(!MULTI) {
solve(1);
} else {
int t; cin>>t;
for(int t_case = 1; t_case <= t; t_case++) solve(t_case);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
748 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
3052 KB |
Output does not have symmetry property |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Extra information in the output file |
2 |
Halted |
0 ms |
0 KB |
- |