// looking to shine brighter in this world...
#ifdef LOCAL
#include "local_header.h"
#include "debugger.h"
#else
#include <bits/stdc++.h>
#define debug(...)
#define DB(...)
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
using namespace std;
const bool __initialization = []() {
cin.tie(nullptr)->sync_with_stdio(false);
#define TASK "empty"
if (fopen(TASK".inp", "r")) {
(void)(!freopen(TASK".inp", "r", stdin));
(void)(!freopen(TASK".out", "w", stdout)); }
cout << setprecision(12) << fixed;
return true;
}();
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define For(i, l, r) for (int i = (l); i <= (r); ++i)
#define Ford(i, r, l) for (int i = (r); i >= (l); --i)
#define Rep(i, n) For (i, 0, (n) - 1)
#define Repd(i, n) Ford (i, (n) - 1, 0)
#define Fe(...) for (auto __VA_ARGS__)
template <class C> inline int isz(const C& c) { return static_cast<int>(c.size()); }
template <class T> inline bool chmin(T& a, const T& b) { return (a > b) ? a = b, true : false; }
template <class T> inline bool chmax(T& a, const T& b) { return (a < b) ? a = b, true : false; }
constexpr ld eps = 1e-9;
constexpr int inf = 1e9;
constexpr ll linf = 1e18;
// =============================================================================
constexpr int maxn = 1e5 + 5;
int n;
int a[maxn];
signed main() {
cin >> n;
For (i, 1, n) cin >> a[i];
if (n == 2) {
cout << 1 << '\n';
cout << a[1] << '\n';
cout << 1 << '\n';
cout << a[2] << '\n';
return 0;
}
sort(a + 1, a + n + 1);
array<array<int, 2>, 3> match = {{
{1, 2},
{2, 3},
{1, 3}
}};
Fe (const& [x, y] : match) {
vector<int> seq;
seq.push_back(x);
seq.push_back(y);
int diff = a[y] - a[x];
For (i, y + 1, n) {
if (isz(seq) == n - 1) break;
if (a[i] - a[seq.back()] == diff) {
seq.push_back(i);
}
}
vector<int> other;
For (i, 1, n) {
if (!binary_search(all(seq), i)) {
other.push_back(i);
}
}
bool ok = true;
if (isz(other) >= 2) {
int d = a[other[1]] - a[other[0]];
Rep (i, isz(other) - 1) {
if (a[other[i + 1]] - a[other[i]] != d) {
ok = false;
break;
}
}
}
if (ok) {
cout << isz(seq) << '\n';
Rep (i, isz(seq)) {
cout << a[seq[i]] << " \n"[i == isz(seq) - 1];
}
cout << isz(other) << '\n';
Rep (i, isz(other)) {
cout << a[other[i]] << " \n"[i == isz(other) - 1];
}
return 0;
}
}
cout << -1 << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
3220 KB |
Output is correct |
2 |
Correct |
28 ms |
3092 KB |
Output is correct |
3 |
Correct |
33 ms |
3096 KB |
Output is correct |
4 |
Correct |
28 ms |
3144 KB |
Output is correct |
5 |
Correct |
30 ms |
3224 KB |
Output is correct |
6 |
Correct |
29 ms |
3144 KB |
Output is correct |
7 |
Correct |
34 ms |
3144 KB |
Output is correct |
8 |
Correct |
36 ms |
3224 KB |
Output is correct |
9 |
Incorrect |
28 ms |
2284 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |