| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1306580 | kduckp | Drvca (COCI19_drvca) | C++20 | 0 ms | 0 KiB |
/*
Author: duxp
Version: 1
Created at: 2025-12-30 20:33
*/
// ✅ Pragmas for Maximum Optimization in Competitive Programming
#pragma GCC optimize("O3,unroll-loops,inline,fast-math")
#pragma GCC target("avx,avx2,fma,sse,sse2,sse3,sse4,popcnt,tune=native")
#pragma GCC optimize("no-stack-protector")
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-variable"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define pb push_back
#define all(x) x.begin() + 1, x.end()
#define nall(x) x.begin(), x.end()
#define vi vector<int>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define debug(x) cerr << #x << " = " << (x) << endl
#define debug2(x, y) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define debug3(x, y, z) cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl
#define trailingzero(x) __builtin_ctzll(x)
#define cntbit1(x) __builtin_popcountll(x)
#define leadingzero(x) __builtin_clzll(x)
#define TDN signed main()
#define KILL() exit(0)
#define NAME "task"
template <typename T>
inline int getbit(T x, int k) { return (x >> k) & 1; }
template <typename T>
inline T onbit(T x, int k) { return x | (T(1) << k); }
template <typename T>
inline T offbit(T x, int k) { return x & ~(T(1) << k); }
template <typename T>
inline bool minimize(T &a, const T &b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
template <typename T>
inline bool maximize(T &a, const T &b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
const ll INF = 1e18;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const int MAXN = 200000;
bool ok(vi a)
{
if (a.size() == 0)
return false;
if (a.size() == 1)
return true;
int diff = a[1] - a[0];
for (int i = 1; i < (int)a.size(); i++)
{
if (a[i] - a[i - 1] != diff)
return false;
}
return true;
}
TDN
{
fast;
string fname = string(NAME);
if (fopen((fname + ".inp").c_str(), "r"))
{
freopen((fname + ".inp").c_str(), "r", stdin);
freopen((fname + ".out").c_str(), "w", stdout);
}
int n;
cin >> n;
vi a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i];
sort(all(a));
vi diff;
for (int i = 1; i <= n; i++)
{
diff.pb(a[i] - a[1]);
}
for (auto d : diff)
{
vector<bool> inA(n + 1, false);
int last = a[1];
inA[1] = true;
for (int j = 2; j <= n; j++)
{
if (a[j] - last == d)
{
last = a[j];
inA[j] = true;
}
}
vi B;
for (int j = 1; j <= n; j++)
{
if (!inA[j])
B.pb(a[j]);
}
if (ok(B))
{
vi A;
for (int j = 1; j <= n; j++)
{
if (inA[j])
A.pb(a[j]);
}
if (!ok(A) || A.size() + B.size() != n)
continue;
sort(nall(A));
sort(nall(B));
cout << A.size() << endl;
for (auto x : A)
cout << x << ' ';
cout << endl;
cout << B.size() << endl;
for (auto x : B)
cout << x << ' ';
cout << endl;
KILL();
}
}
cout << -1;
KILL();
}
