# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1273261 | SmuggingSpun | Lampice (COCI21_lampice) | C++20 | 1 ms | 348 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n, k;
cin >> n >> k;
vector<int>a(n + 1);
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int len = 1; len <= n; len++){
if(len % k == 0){
for(int l = n - len + 1; l > 0; l--){
int r = l + len - 1, L = len / k;
bool f = true;
for(int i = l; i + L - 1 <= r; i += L){
for(int j = 0; j < L; j++){
if(a[l + j] != a[i + j]){
f = false;
break;
}
}
}
if(f){
cout << L << "\n";
for(int j = 0; j < L; j++){
cout << a[l + j] << " ";
}
return 0;
}
}
}
}
cout << -1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |