# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201170 | rzbt | Drvca (COCI19_drvca) | C++14 | 52 ms | 3400 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>
#define MAXN 100005
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n;
int visine[MAXN];
vector<int> a,b;
bool provera(){
if(b.empty()){
b.pb(a.back());
a.pop_back();
return true;
}
for(int i=2;i<b.size();i++){
if(b[i]-b[i-1]!=b[i-1]-b[i-2])return false;
}
return true;
}
void ispis(){
printf("%d\n",a.size());
for(auto x:a)printf("%d ",x);
printf("\n%d\n",b.size());
for(auto x:b)printf("%d ",x);
exit(0);
}
int main()
{
scanf("%d", &n);
for(int i=0;i<n;i++)scanf("%d",visine+i);
if(n==2){
printf("1\n%d\n1\n%d\n",visine[1],visine[0]);
}
sort(visine,visine+n);
a.pb(visine[0]);
a.pb(visine[1]);
for(int i=2;i<n;i++){
if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]);
else b.pb(visine[i]);
}
if(provera())ispis();
a.clear();
b.clear();
/// /////////////////////
a.pb(visine[0]);
a.pb(visine[2]);
b.pb(visine[1]);
for(int i=3;i<n;i++){
if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]);
else b.pb(visine[i]);
}
if(provera())ispis();
a.clear();
b.clear();
/// /////////////////////
a.pb(visine[1]);
a.pb(visine[2]);
b.pb(visine[0]);
for(int i=3;i<n;i++){
if(visine[i]-a.back()==a.back()-a[a.size()-2])a.pb(visine[i]);
else b.pb(visine[i]);
}
if(provera())ispis();
a.clear();
b.clear();
printf("-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... |