Submission #1017506

# Submission time Handle Problem Language Result Execution time Memory
1017506 2024-07-09T08:33:29 Z vjudge1 Lampice (COCI21_lampice) C++17
0 / 50
0 ms 348 KB
#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

Main.cpp: In function 'int32_t main()':
Main.cpp:24:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int i=0; i<p.size(); i+=0){
      |                ~^~~~~~~~~
Main.cpp:39: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]
   39 |    for(int i=0; i<ans.size(); ++i){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Sequence doesn't repeat k times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -