Submission #489190

#TimeUsernameProblemLanguageResultExecution timeMemory
489190jalsolDrvca (COCI19_drvca)C++17
0 / 110
37 ms3224 KiB
// 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'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...