Submission #811189

#TimeUsernameProblemLanguageResultExecution timeMemory
811189pccDrvca (COCI19_drvca)C++14
0 / 110
60 ms7656 KiB
#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;
	for(int i = 0;i<n;i++)st.insert(arr[i]);
	while(st.find(now) != st.end()){
		st.erase(st.find(now));
		v.push_back(now);
		now += d;
	}
	vector<ll> tmp;
	for(auto &i:st)tmp.push_back(i);

	if(tmp.empty()){
		tmp.push_back(v.back());
		v.pop_back();
	}
	if(tmp.size()<=2){
		cout<<v.size()<<'\n';
		for(auto &i:v)cout<<i<<' ';cout<<'\n';
		cout<<tmp.size()<<'\n';
		for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
		exit(0);
	}
	d = tmp[1]-tmp[0];
	for(int i = 1;i<tmp.size();i++){
		if(tmp[i]-tmp[i-1] != d)return;
	}
	cout<<v.size()<<'\n';
	for(auto &i:v)cout<<i<<' ';cout<<'\n';
	cout<<tmp.size()<<'\n';
	for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
	exit(0);
}

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)

drvca.cpp: In function 'void check(long long int, long long int)':
drvca.cpp:34:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:34:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   34 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                              ^~~~
drvca.cpp:36:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   36 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:36:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                                ^~~~
drvca.cpp:40:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for(int i = 1;i<tmp.size();i++){
      |                ~^~~~~~~~~~~
drvca.cpp:44:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:44:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                             ^~~~
drvca.cpp:46:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:46:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                               ^~~~
drvca.cpp: At global scope:
drvca.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...