Submission #442941

# Submission time Handle Problem Language Result Execution time Memory
442941 2021-07-09T11:32:24 Z Wasif_Jamil Drvca (COCI19_drvca) C++14
20 / 110
51 ms 588 KB
// "Say:He is the Most Merciful,We have believed in him and upon him we have relied" [67:29]

#include<bits/stdc++.h>
using namespace std;

bool is(vector<int>&v){
	if((int)v.size() == 1)return 1;
	int d = abs(v[0] - v[1]);
	for(int i=0; i<(int)v.size()-1; i++){
		if((v[i+1] - v[i]) != d)return 0;
	}
	return 1;
}

int main(){
	int n; cin >> n;
	vector<int>v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for(int i=1; i<(1 << n)-1; i++){
		vector<int>a, b;
		for(int j=0; j<n; j++){
			if(i & (1 << j)){
				a.push_back(v[j]);
			}else {
				b.push_back(v[j]);
			}
		}
		if(is(a) and is(b)){
			cout << a.size() << '\n';
			for(int e:a)cout << e << ' ';
			cout << '\n';
			cout << (int)b.size() << '\n';
			for(int e:b)cout << e << ' ';
			cout << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 7 ms 288 KB Output is correct
3 Correct 5 ms 204 KB Output is correct
4 Correct 14 ms 284 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 7 ms 288 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 14 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 7 ms 288 KB Output is correct
3 Correct 5 ms 204 KB Output is correct
4 Correct 14 ms 284 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 7 ms 288 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 14 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 5 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 7 ms 288 KB Output is correct
3 Correct 5 ms 204 KB Output is correct
4 Correct 14 ms 284 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 7 ms 288 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 14 ms 292 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 288 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Incorrect 5 ms 204 KB Output isn't correct
16 Halted 0 ms 0 KB -