Submission #811167

# Submission time Handle Problem Language Result Execution time Memory
811167 2023-08-07T01:35:08 Z pcc Drvca (COCI19_drvca) C++14
0 / 110
59 ms 7712 KB
#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()){
		cout<<v.size()-1<<'\n';
		for(int i = 0;i<v.size()-1;i++)cout<<v[i]<<' ';
		cout<<"\n1\n"<<v.back()<<'\n';
		exit(0);
	}
	else 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);
	check(arr[0],arr[1]-arr[0]);
	if(n>2){
		check(arr[0],arr[2]-arr[0]);
		check(arr[1],arr[2]-arr[1]);
	}
	cout<<"-1";
	return 0;
}

Compilation message

drvca.cpp: In function 'void check(long long int, long long int)':
drvca.cpp:29:18: 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]
   29 |   for(int i = 0;i<v.size()-1;i++)cout<<v[i]<<' ';
      |                 ~^~~~~~~~~~~
drvca.cpp:35:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   35 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:35:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |   for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                              ^~~~
drvca.cpp:37:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |   ^~~
drvca.cpp:37:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |   for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                                ^~~~
drvca.cpp:41: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]
   41 |  for(int i = 1;i<tmp.size();i++){
      |                ~^~~~~~~~~~~
drvca.cpp:45:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:45:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |  for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                             ^~~~
drvca.cpp:47:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   47 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |  ^~~
drvca.cpp:47:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   47 |  for(auto &i:tmp)cout<<i<<' ';cout<<'\n';
      |                               ^~~~
drvca.cpp: At global scope:
drvca.cpp:51:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   51 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 7600 KB Output is correct
2 Correct 40 ms 6696 KB Output is correct
3 Correct 42 ms 7680 KB Output is correct
4 Correct 36 ms 6736 KB Output is correct
5 Correct 42 ms 7712 KB Output is correct
6 Correct 36 ms 6680 KB Output is correct
7 Correct 42 ms 7608 KB Output is correct
8 Correct 36 ms 6728 KB Output is correct
9 Incorrect 59 ms 7068 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -