제출 #443149

#제출 시각아이디문제언어결과실행 시간메모리
443149Dipto_DebdipDrvca (COCI19_drvca)C++14
20 / 110
96 ms8124 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;
  cin >> n;
  vector<ll> v;
  for (ll i = 0; i < n; i++) cin >> k, v.push_back(k);
  sort(v.begin(), v.end());
  for (ll i = 0; i < (1 << n); i++) {
    vector<ll> ano;
    map<ll, ll> mp;
    for (ll j = 0; j < n; j++) {
      if (i & (1 << j)) ano.push_back(v[j]), mp[j]++;
    }
    vector<ll> anoo;
    for (ll j = 0; j < n; j++) if (!mp[j]) anoo.push_back(v[j]);
    if (anoo.size() && ano.size() && chk(ano) && chk(anoo)) {
      cout << ano.size() << endl;
      for (ll j : ano) cout << j << " ";
      cout << endl;
      cout << anoo.size() << endl;
      for (ll j : anoo) cout << j << " ";
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  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...