답안 #811204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
811204 2023-08-07T02:25:49 Z pcc Drvca (COCI19_drvca) C++14
110 / 110
114 ms 8472 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;
	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

drvca.cpp: In function 'void check(long long int, long long int)':
drvca.cpp:51:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |    for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |    ^~~
drvca.cpp:51:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |    for(auto &i:v)cout<<i<<' ';cout<<'\n';
      |                               ^~~~
drvca.cpp:53:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   53 |    for(auto &i:st)cout<<i<<' ';cout<<'\n';
      |    ^~~
drvca.cpp:53:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   53 |    for(auto &i:st)cout<<i<<' ';cout<<'\n';
      |                                ^~~~
drvca.cpp: At global scope:
drvca.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main(){
      | ^~~~
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 7496 KB Output is correct
2 Correct 37 ms 6728 KB Output is correct
3 Correct 44 ms 7236 KB Output is correct
4 Correct 40 ms 6752 KB Output is correct
5 Correct 61 ms 7656 KB Output is correct
6 Correct 41 ms 6784 KB Output is correct
7 Correct 62 ms 7536 KB Output is correct
8 Correct 39 ms 6688 KB Output is correct
9 Correct 38 ms 6484 KB Output is correct
10 Correct 42 ms 8072 KB Output is correct
11 Correct 29 ms 7688 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 332 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 61 ms 7496 KB Output is correct
32 Correct 37 ms 6728 KB Output is correct
33 Correct 44 ms 7236 KB Output is correct
34 Correct 40 ms 6752 KB Output is correct
35 Correct 61 ms 7656 KB Output is correct
36 Correct 41 ms 6784 KB Output is correct
37 Correct 62 ms 7536 KB Output is correct
38 Correct 39 ms 6688 KB Output is correct
39 Correct 38 ms 6484 KB Output is correct
40 Correct 42 ms 8072 KB Output is correct
41 Correct 29 ms 7688 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 59 ms 8472 KB Output is correct
44 Correct 114 ms 7856 KB Output is correct
45 Correct 36 ms 7096 KB Output is correct
46 Correct 40 ms 7668 KB Output is correct
47 Correct 75 ms 7556 KB Output is correct
48 Correct 36 ms 7116 KB Output is correct
49 Correct 58 ms 8024 KB Output is correct
50 Correct 60 ms 6924 KB Output is correct
51 Correct 36 ms 7176 KB Output is correct
52 Correct 41 ms 7744 KB Output is correct
53 Correct 73 ms 7476 KB Output is correct
54 Correct 36 ms 7096 KB Output is correct
55 Correct 43 ms 7772 KB Output is correct
56 Correct 37 ms 7692 KB Output is correct
57 Correct 30 ms 7672 KB Output is correct
58 Correct 0 ms 336 KB Output is correct