답안 #1017206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017206 2024-07-09T06:25:02 Z vjudge1 Lampice (COCI21_lampice) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

bool check(vector<int> const&a, int l, int r, int k) {
	int patsize = (r - l + 1) / k;
	vector<int> pattern(patsize);
	for(int i = l; i < l + patsize; i++) {
		pattern[i - l] = a[i];
	}
	for(int j = l + patsize; j < r + (patsize == 1 ? 1 : 0); j += patsize) {
		for(int i = j; i < j + patsize; i ++) {
			if(pattern[i - j] != a[i]) return false;
		}
	}
	return true;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(auto &x:a) cin >> x;
	for(int i = 0; i < n; i ++) {
		for(int j = i; j < n; j ++) {
			if((j - i + 1) % k != 0) continue;
			bool flag = check(a, i, j, k);
			if(flag) {
				cout << (j - i + 1) / k << '\n';
				for(int t = i; t < i + ((j - i + 1) / k); t ++) {
					cout << a[t] << ' ';
				}
				cout << '\n';
				return 0;
			}
		}
	}
	cout << "-1\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct