# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
811203 | pcc | Drvca (COCI19_drvca) | C++14 | 127 ms | 7408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 1e5+10;
int n;
ll arr[mxn];
void check(ll start,ll d){
ll now = start;
multiset<ll> st;
vector<ll> v;
map<ll,ll> mp;
for(int i = 0;i<n;i++)st.insert(arr[i]);
for(auto it = ++st.begin();it != st.end();it++){
mp[*it-*prev(it)]++;
}
while(st.find(now) != st.end()){
v.push_back(now);
auto it = st.find(now);
now+= d;
///cout<<start<<' '<<d<<' '<<now<<":";for(auto &i:mp)cout<<i.fs<<','<<i.sc<<' ';cout<<'\n';
//for(auto &i:st)cout<<i<<' ';cout<<'\n';
if(it != st.begin()){
ll dd = *it-*prev(it);
mp[dd]--;
if(mp[dd] == 0)mp.erase(dd);
}
if(it != --st.end()){
ll dd = *next(it)-*it;
mp[dd]--;
if(mp[dd] == 0)mp.erase(dd);
}
if(it != st.begin()&&it != st.end()){
ll dd = *next(it)-*prev(it);
mp[dd]++;
}
st.erase(it);
if(mp.size() == 1){
if(st.empty()){
st.insert(v.back());
v.pop_back();
}
cout<<v.size()<<'\n';
for(auto &i:v)cout<<i<<' ';cout<<'\n';
cout<<st.size()<<'\n';
for(auto &i:st)cout<<i<<' ';cout<<'\n';
exit(0);
}
}
return;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i = 0;i<n;i++)cin>>arr[i];
sort(arr,arr+n);
if(n<=2){
cout<<"1\n"<<arr[0]<<'\n'<<"1\n"<<arr[1]<<'\n';
exit(0);
}
check(arr[0],arr[1]-arr[0]);
check(arr[0],arr[2]-arr[0]);
check(arr[1],arr[2]-arr[1]);
cout<<"-1";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |