Submission #198287

#TimeUsernameProblemLanguageResultExecution timeMemory
198287alradDrvca (COCI19_drvca)C++17
0 / 110
54 ms1756 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base :: sync_with_stdio(0); cin.tie(0) , cout.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin() , a.end()); if (n == 2) { cout << 1 << '\n' << a[0] << '\n'; cout << 1 << '\n' << a[1] << '\n'; return 0; } auto run = [&](int x , int y) { int d1 = a[y] - a[x] , p1 = a[y]; vector<int> seq1; seq1.push_back(a[x]); seq1.push_back(a[y]); for (int i = 0; i < n; i++) { if (i == x || i == y) { continue; } int d2 = -1 , p2 = a[i]; vector<int> seq2; seq2.push_back(a[i]); bool good = true; for (int j = 0; j < n; j++) { if (j == i || j == x || j == y) { continue; } if (a[j] - p1 == d1) { //add to 1 seq seq1.push_back(a[j]); p1 = a[j]; } else if (d2 == -1 || a[j] - p2 == d2) { seq2.push_back(a[j]); if (d2 == -1) { d2 = a[j] - p2; } p2 = a[j]; } else { good = false; break; } } if (good) { cout << (int)seq1.size() << '\n'; for (int num : seq1) { cout << num << " "; } cout << '\n'; cout << (int)seq2.size() << '\n'; for (int num : seq2) { cout << num << " "; } cout << '\n'; exit(0); return; } } return; }; run(0 , 1); run(0 , 2); run(1 , 2); 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...