이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
# define int long long
//# define double long double
# define all(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
# define pi pair<int, int>
# define f first
# define s second
using namespace std;
void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int l = 0; l < n; ++l) {
        for (int r = l; r < n; ++r) {
            int len = r - l + 1;
            if (len % k) continue;
            int c = len / k;
            bool b = true;
            for (int i = l; i <= r - c; ++i) {
                if (a[i] != a[i + c]) {
                    b = false;
                    break;
                }
            }
            if (b) {
                cout << c << "\n";
                for (int i = l; i < l + c; ++i) {
                    cout << a[i] << " ";
                }
                cout << "\n";
                return;
            }
        }
    }
    cout << -1 << "\n";
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |