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;
int n;
vector <bool> used;
vector <int> a;
void funct1()
{
int diff = a[1] - a[0];
vector <int> vec1;
used[0] = 1;
vec1.push_back(a[0]);
for(int j = 1; j < n / 2; j++)
{
int it = lower_bound(a.begin(), a.end(), vec1.back() + diff) - a.begin();
if(it != a.size() && a[it] == vec1.back() + diff)
{
vec1.push_back(a[it]);
used[it] = 1;
}
else
{
return;
}
}
vector <int> vec2;
for(int j = 0; j < n; j++)
{
if(!used[j])
{
vec2.push_back(a[j]);
}
}
for(int j = 1; j < n / 2 - 1; j++)
{
if(vec2[j] - vec2[j - 1] != vec2[j + 1] - vec2[j])
{
return;
}
}
cout << vec1.size() << "\n";
for(int i = 0; i < vec1.size(); i++)
{
cout << vec1[i] << " ";
}
cout << "\n";
cout << vec2.size() << "\n";
for(int i = 0; i < vec2.size(); i++)
{
cout << vec2[i] << " ";
}
exit(0);
}
void funct2()
{
int diff = a[2] - a[0];
vector <int> vec1;
used[0] = 1;
vec1.push_back(a[0]);
for(int j = 1; j < n / 2; j++)
{
int it = lower_bound(a.begin(), a.end(), vec1.back() + diff) - a.begin();
if(it != a.size() && a[it] == vec1.back() + diff)
{
vec1.push_back(a[it]);
used[it] = 1;
}
else
{
return;
}
}
vector <int> vec2;
for(int j = 0; j < n; j++)
{
if(!used[j])
{
vec2.push_back(a[j]);
}
}
for(int j = 1; j < n / 2 - 1; j++)
{
if(vec2[j] - vec2[j - 1] != vec2[j + 1] - vec2[j])
{
return;
}
}
cout << vec1.size() << "\n";
for(int i = 0; i < vec1.size(); i++)
{
cout << vec1[i] << " ";
}
cout << "\n";
cout << vec2.size() << "\n";
for(int i = 0; i < vec2.size(); i++)
{
cout << vec2[i] << " ";
}
exit(0);
}
void funct3()
{
int diff = a[2] - a[1];
vector <int> vec1;
used[0] = 1;
vec1.push_back(a[1]);
for(int j = 1; j < n / 2; j++)
{
int it = lower_bound(a.begin(), a.end(), vec1.back() + diff) - a.begin();
if(it != a.size() && a[it] == vec1.back() + diff)
{
vec1.push_back(a[it]);
used[it] = 1;
}
else
{
return;
}
}
vector <int> vec2;
for(int j = 0; j < n; j++)
{
if(!used[j])
{
vec2.push_back(a[j]);
}
}
for(int j = 1; j < n / 2 - 1; j++)
{
if(vec2[j] - vec2[j - 1] != vec2[j + 1] - vec2[j])
{
return;
}
}
cout << vec1.size() << "\n";
for(int i = 0; i < vec1.size(); i++)
{
cout << vec1[i] << " ";
}
cout << "\n";
cout << vec2.size() << "\n";
for(int i = 0; i < vec2.size(); i++)
{
cout << vec2[i] << " ";
}
exit(0);
}
signed main(){
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
cin >> n;
a.resize(n);
used.resize(n);
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
sort(a.begin(), a.end());
funct1();
for(int i = 0; i < n; i++)
{
used[i] = 0;
}
funct2();
for(int i = 0; i < n; i++)
{
used[i] = 0;
}
funct3();
cout << -1;
return 0;
}
Compilation message (stderr)
drvca.cpp: In function 'void funct1()':
drvca.cpp:16:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(it != a.size() && a[it] == vec1.back() + diff)
~~~^~~~~~~~~~~
drvca.cpp:42:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec1.size(); i++)
~~^~~~~~~~~~~~~
drvca.cpp:48:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec2.size(); i++)
~~^~~~~~~~~~~~~
drvca.cpp: In function 'void funct2()':
drvca.cpp:63:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(it != a.size() && a[it] == vec1.back() + diff)
~~~^~~~~~~~~~~
drvca.cpp:89:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec1.size(); i++)
~~^~~~~~~~~~~~~
drvca.cpp:95:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec2.size(); i++)
~~^~~~~~~~~~~~~
drvca.cpp: In function 'void funct3()':
drvca.cpp:110:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(it != a.size() && a[it] == vec1.back() + diff)
~~~^~~~~~~~~~~
drvca.cpp:136:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec1.size(); i++)
~~^~~~~~~~~~~~~
drvca.cpp:142:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec2.size(); i++)
~~^~~~~~~~~~~~~
# | 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... |