Submission #223639

#TimeUsernameProblemLanguageResultExecution timeMemory
223639Haunted_CppDrvca (COCI19_drvca)C++17
0 / 110
5 ms640 KiB
#include <iostream> #include <cstring> #include <algorithm> #include <vector> #pragma GCC optimize ("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; const int N = 2e3; int a [N]; bool vis [N]; int main () { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort (a, a + n); for (int i = 0; i < n; i++) { vector<int> up = {a[0]}, down; if (i) up.emplace_back(a[i]); const int diff = a[i] - a[0]; int nxt = a[i] + (a[i] - a[0]); for (int j = 1; j < n; j++) { if (j == i) continue; if (a[j] == nxt) { up.emplace_back(a[j]); nxt += diff; } else { down.emplace_back(a[j]); } } if ((int) down.size() <= 1) { while ((int) down.size() == 0) { int l = up.back (); up.pop_back (); down.emplace_back(l); } cout << (int) up.size() << '\n'; for (auto to : up) cout << to << ' '; cout << '\n'; cout << (int) down.size() << '\n'; for (auto to : down) cout << to << ' '; cout << '\n'; return 0; } const int d = down[1] - down[0]; for (int j = 1; j < (int) down.size(); j++) { if (down[j] - down[j - 1] != d) { goto fim; } } cout << (int) up.size() << '\n'; for (auto to : up) cout << to << ' '; cout << '\n'; cout << (int) down.size() << '\n'; for (auto to : down) cout << to << ' '; cout << '\n'; return 0; fim:; } cout << -1 << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...