//ojou kawayo no.1
#include <bits/stdc++.h>
using namespace std;
#define tsk "drvca"
#define pb push_back
#define pf push_front
//dm define endl
#define fi first
#define se second
#define Ningen_sama signed
#define tachi main()
#define __builtin_popcount __builtin_popcountll
#define el cout<<'\n'
#define all(a) a.begin(),a.end()
#define invAll(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define BIT(x, k) (1ll&(x >> k))
#define len(s) (int)s.size()
#define mem(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << " = " << x << '\n'
#define execute cerr << "Time elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << "s"
#define FOR(i, l, r) for(int i = (l), _r = (r); i <= _r; ++i)
#define FORD(i, l, r) for(int i = (l), _r = (r); i >= _r; --i)
#define REP(i, n) for(int i = 0, _n = (n); i < _n; ++i)
//#define int long long
template<class T> bool maximize(T& u, T v){if(u >= v) return false;return u = v, true;}
template<class T> bool minimize(T& u, T v){if(u <= v) return false;return u = v, true;}
using pii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vpii = vector<pair<int, int>>;
#define inf32 0x3f3f3f3f
#define inf64 0x3f3f3f3f3f3f3f3f
const int maxn = 1e6+5;
const int N = 5e3 + 5;
const int base = 31;
const ll mod = 1e9 + 7;
const ll need = 67108863;
const int vc = 2e9 + 1;
const ll INF18 = 4557430888798830399;
const ll LOG = 20;
const double eps = 1e-9;
const int BLOCK = 447;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
#define rand rd
inline long long Rand(long long L, long long R) {
if(L>R) return 0;
return L + rd() % (R - L + 1);
}
inline ll add(ll x, ll y){x+=y;if(x>=mod) x-=mod;if(x<0) x+=mod;return x;}
inline ll mult(ll x, ll y){return 1LL * x * y % mod;}
int n;
int a[maxn];
void check(int A, int B){
multiset<int> s, diff;
FOR(i, 1, n) s.insert(a[i]);
s.erase(s.find(A));
s.erase(s.find(B));
vi ans;
ans.pb(A);
ans.pb(B);
int last = - 1;
for(int x : s){
if(last != - 1) diff.insert(x - last);
last = x;
}
int delta = B - A;
int tmp = B + delta;
do{
if(*diff.begin() == *diff.rbegin()){
cout << sz(ans); el;
for(int v : ans) cout << v << " ";el;
cout << sz(s); el;
for(int v : s) cout << v << " ";
exit(0);
}
auto it = s.find(tmp);
if(it == s.end()) break;
auto l = it, r = it;
if(it != s.begin()){
l--;
diff.erase(diff.find(*it - *l));
}
r++;
if(r != s.end()){
diff.erase(diff.find(*r - *it));
if(it != s.begin()) diff.insert(*r - *l);
}
s.erase(it);
ans.pb(tmp);
tmp += delta;
}while(sz(ans) < n);
}
inline void init(){
}
inline void input(){
cin >> n;
FOR(i, 1, n){
cin >> a[i];
}
}
inline void solve(){
vector<int> v1, v2;
sort(a + 1, a + 1 + n);
if(n <= 4){
cout << n / 2; el;
FOR(i, 1, n / 2) cout << a[i] << " "; el;
cout << n - n / 2; el;
FOR(i, n / 2 + 1, n) cout << a[i] << " "; el;
}
else{
check(a[1], a[2]);
check(a[1], a[3]);
check(a[2], a[3]);
cout << -1;
}
}
Ningen_sama tachi{
//konnakiri~~
if(fopen(tsk".inp","r")){
freopen(tsk".inp","r",stdin);
freopen(tsk".out","w",stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int Yodayo = 1;
//cin >> Yodayo;
//init();
while(Yodayo--){
input();
solve();
}
//execute;
}
//otsunakiri~~
Compilation message (stderr)
drvca.cpp: In function 'int main()':
drvca.cpp:142:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
142 | freopen(tsk".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
drvca.cpp:143:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
143 | freopen(tsk".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | 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... |