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>
using std::vector;
using std::array;
using std::pair;
using std::tuple;
bool check(const vector<int>& v) {
const int n = v.size();
if (n == 0) return false;
if (n == 1) return true;
const int dif = v[1] - v[0];
if (dif < 0) return false;
for (int i = 0; i < n - 1; ++i) {
if (v[i + 1] - v[i] != dif) return false;
}
return true;
}
void show(const vector<int>& v) {
const int n = v.size();
std::cout << n << '\n';
for (int i = 0; i < n; ++i) {
std::cout << v[i] << " \n"[i + 1 == n];
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
std::cin >> N;
vector<int> A(N);
for (auto& x : A) {
std::cin >> x;
}
std::sort(A.begin(), A.end());
assert(N <= 15);
for (int set = 1; set < (1 << N) - 1; ++set) {
vector<int> up, down;
for (int i = 0; i < N; ++i) {
(set >> i & 1 ? up : down).push_back(A[i]);
}
if (check(up) and check(down)) {
show(up);
show(down);
return 0;
}
}
std::cout << "-1\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... |