#include <bits/stdc++.h>
using namespace std;
// Do you think you'll ever remember me someday, or will I just fade away from your memory?
#define LIFESUCK ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define str string
#define mll map<ll, ll>
#define vll vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define all(c) c.begin(), c.end()
#define pb push_back
#define debug cout << "I Love You\n";
#define fu(i, a, b) for (int i = a; i <= b; i++)
#define fd(i, b, a) for (int i = b; i >= a; i--)
#define Bitc(msk, j) ((msk >> j) & 1)
#define _log(x) 31 - __builtin_clz(x)
const ll Mod = 1e9 + 7;
const ll inf = (1ll << 30);
const ll lnf = (1ll << 60);
// When time passes and things change... will you still remember someone like me?
int64_t add(ll &a, ll b) {
a += b;
if (a >= Mod) a %= Mod;
while (a < 0) a += Mod;
return a;
}
int64_t mul(ll a, ll b) {
a = 1ll * a * b % Mod;
return a;
}
template <class X, class Y>
bool minimize(X &x, Y y) {
X eps = 1e-9;
if (x > y + eps) {
x = y;
return 1;
}
return 0;
}
template <class X, class Y>
bool maximize(X &x, Y y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
return 1;
}
return 0;
}
// I wonder… will I just become a distant memory to you one day?
#define mxn 100'007
ll n, g[mxn];
namespace Love1 {
bool check () {
return (n <= 15);
}
bool chk (vll&a) {
if(a.size() == 1) return 1;
ll diff = a[1] - a[0];
fu(i, 1, a.size() - 1) if(a[i] - a[i - 1] != diff) return 0;
return 1;
}
void DreamyLove () {
vll ans1, ans2;
fu(msk, 1, (1 << n) - 2) {
vll a, b;
fu(j, 0, n - 1) {
if(Bitc(msk, j)) a.pb(g[j + 1]);
else b.pb(g[j + 1]);
}
sort(all(a)); sort(all(b));
if(chk(a) && chk(b)) {
cout << a.size() << '\n';
for(auto&i: a) cout << i << ' ';
cout << '\n';
cout << b.size() << '\n';
for(auto&i: b) cout << i << ' ';
return;
}
}
cout << -1;
//
}
}
namespace Love2 {
bool check () {
return (n <= 300);
}
bool chk (vll&a) {
if(a.size() == 1) return 1;
ll diff = a[1] - a[0];
fu(i, 1, a.size() - 1) if(a[i] - a[i - 1] != diff) return 0;
return 1;
}
void DreamyLove () {
sort(g + 1, g + 1 + n);
vll b;
fu(i, 2, n) {
vll res = b, a;
a.pb(g[1]); a.pb(g[i]);
fu(j, i + 1, n){
if(g[j] - a.back() != a[1] - a[0]) res.pb(g[j]);
else a.pb(g[j]);
}
if(chk(res) && res.size() != 0) {
cout << a.size() << '\n';
for(auto&i: a) cout << i << ' ';
cout << '\n';
cout << res.size() << '\n';
for(auto&i: res) cout << i << ' ';
return;
}
if(b.size() < 2) b.pb(g[i]);
else {
if(g[i] - b.back() != b[1] - b[0]) return void(cout << -1);
else b.pb(g[i]);
}
}
//
}
}
void lovesper(const ll &TestCase) {
cin >> n;
fu(i, 1, n) cin >> g[i];
if(Love1::check()) {
Love1::DreamyLove();
return;
}
// if(Love2::check()) {
Love2::DreamyLove();
// return;
// }
}
signed main() {
LIFESUCK
#define name "lovesper"
// freopen(name".inp", "r", stdin);
// freopen(name".out", "w", stdout);
ll Test = 1;
// cin >> Test;
fu(i, 1, Test) {
lovesper(i);
if (i < Test) cout << '\n';
}
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... |