| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1017506 | vjudge1 | Lampice (COCI21_lampice) | C++17 | 0 ms | 348 KiB | 
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>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define endl ('\n')
using namespace std;
int32_t main(){
	fast
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i=0; i<n; ++i){
		cin >> v[i];
	}
	if(k == 2){
		deque<int> p;
		vector<int> ans;
		int cnt = 0;
		for(int i=0; i<n; ++i){
			if(v[i] != v[i + 1]) p.push_back(v[i]);
		}
		if(v[n - 1] != v[n - 2]) p.push_back(v[n - 2]);
		for(int i=0; i<p.size(); i+=0){
			int x = p.size();
			if(p.size() % 2 == 1) x++;
			if(p[i] != p[(x / 2) + i]){
				p.pop_front();
			}
			else{
				cnt++;
				ans.push_back(v[i]);
				i++;
			}
		}
		if(ans.size() < 2) cout << -1;
		else{
			cout << cnt << "\n";
			for(int i=0; i<ans.size(); ++i){
				cout << v[i] << " ";
			}
		}
	}
	else{
		int a = 0;
		int c = v[0];
		for(int i=1; i<n; ++i){
			if(v[i] == v[i - 1]){
				a++;
			}
		}
		if(a == n - 1){
			cout << 1 << "\n";
			cout << c;
		}
	}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
