Submission #443141

#TimeUsernameProblemLanguageResultExecution timeMemory
443141Dipto_DebdipDrvca (COCI19_drvca)C++14
0 / 110
1088 ms143204 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long int bool chk(vector<ll> v) { set<ll> st; for (ll i = 0; i < (ll) (v.size()) - 1; i++) { st.insert(v[i] - v[i + 1]); } return (st.size() == 1 || st.size() == 0); } int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, k; vector<ll> v; map<ll, ll> mp; cin >> n; for (ll i = 0; i < n; i++) { cin >> k; mp[k]++; v.push_back(k); } set<ll> st; sort(v.begin(), v.end()); for (ll i = 0; i < n; i++) { for (ll j = i + 1; j < n; j++) { st.insert(v[j] - v[i]); } } ll f = 0; for (ll c : st) { if (c == 0) continue; //cout << "c = " << c << endl; for (ll i = 0; i < n; i++) { vector<ll> f = {v[i]}; map<ll, ll> mp2; mp2[v[i]]++; ll ff = 2; while (ff) { map<ll, ll> cop; for (ll jj : f) cop[jj]++; vector<ll> s; for (ll j : v) { if (cop[j]) cop[j]--; else s.push_back(j); } //cout << "hi" << endl; //s.erase(s.begin()); if (chk(s) && chk(f) && (ll) (s.size() + (ll) f.size()) == n) { cout << f.size() << endl; for (ll i : f) cout << i << " "; cout << endl; cout << s.size() << endl; for (ll j : s) cout << j << " "; cout << endl; return 0; } if (mp[f.back() + c] == 0) ff--; else f.push_back(f.back() + c); } } } if (*st.begin() == 0 && st.size() == 1) { cout << 1 << " " << v[0] << endl; cout << n - 1 << endl; for (ll i = 1; i < n; i++) cout << v[i] << " "; cout << endl; return 0; } cout << -1 << endl; return 0; }

Compilation message (stderr)

drvca.cpp: In function 'int main(int, const char**)':
drvca.cpp:30:6: warning: unused variable 'f' [-Wunused-variable]
   30 |   ll f = 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...