Submission #516284

# Submission time Handle Problem Language Result Execution time Memory
516284 2022-01-21T02:38:29 Z penguinhacker Lampice (COCI21_lampice) C++14
0 / 50
1 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=50;
int n, k, a[mxN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	for (int i=0; i<n; ++i)
		for (int j=i; j<n; ++j) {
			if ((j-i+1)%k!=0)
				continue;
			int len=(j-i+1)/k;
			bool ok=1;
			for (int k=j; k<=j; ++k)
				ok&=a[k]==a[(k-i)%len+i];
			if (ok) {
				cout << len << "\n";
				for (int k=0; k<len; ++k)
					cout << a[i+k] << " ";
				return 0;
			}
		}
	cout << -1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Sequence doesn't repeat k times
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Sequence doesn't repeat k times
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Sequence doesn't repeat k times
7 Halted 0 ms 0 KB -