제출 #1307504

#제출 시각아이디문제언어결과실행 시간메모리
1307504ikkyuLampice (COCI21_lampice)C++20
50 / 50
1 ms352 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAX = 1010;
int n, k;
int a[MAX];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for (int i = 1; k * i <= n; ++i){
        for (int st = 1, en = k * i; en <= n; ++st, ++en){
            bool flag = true;
            for (int lf = st; lf <= en; lf += i){
                for (int j = 0; j < i; ++j){
                    if (a[st + j] != a[lf + j]){
                        flag = false;
                        break;
                    }
                }
            }
            if (flag){
                cout << i << '\n';
                for (int j = 0; j < i; ++j){
                    cout << a[st + j] << ' ';
                }
                return 0;
            }
        }
    }
    cout << -1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...