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 fastio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
using namespace std ;
int n , k ;
set <int> st ;
vector <int> v , a , ans ;
bool check ()
{
st.clear() ;
for ( int i = 0 ; i < n ; i++ ) st.insert(v[i]+v[n-i-1]) ;
if ( st.size() == 1 ) return 1 ;
return 0 ;
}
void bt ( int i , int cnt )
{
if ( i == n + k )
{
if ( cnt == n )
if ( check () )
{
ans.clear() ;
for ( int i = 0 ; i < n ; i++ ) ans.push_back(v[i]) ;
}
return ;
}
v.push_back(a[i]) ;
bt ( i + 1 , cnt + 1 ) ;
v.pop_back() ;
bt ( i + 1 , cnt ) ;
}
signed main ()
{
fastio ;
cin >> n >> k ;
a.resize(n+k) ;
for ( int i = 0 ; i < n + k ; i++ ) cin >> a[i] ;
bt ( 0 , 0 ) ;
for ( auto it : ans ) cout << it << " " ;
return 0 ;
}
# | 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... |