Submission #638799

# Submission time Handle Problem Language Result Execution time Memory
638799 2022-09-07T13:55:51 Z NotLinux Lampice (COCI21_lampice) C++14
0 / 50
1 ms 320 KB
/**
 * author: NotLinux
 * created: 07.09.2022 ~ 15:01:43
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
    #include "/home/notlinux/debug.h"
#else
    #define debug(x...) void(37)
#endif
vector < int > arr;
bool Is_same(int l , int r){
    vector < int > v1,v2;
    for(int i = l;i<=(l+r)/2;i++){
        v1.push_back(arr[i]);
    }
    for(int i = (l+r)/2+1;i<=r;i++){
        v2.push_back(arr[i]);
    }
    debug(l,r,v1,v2,(v1==v2));
    return (v1 == v2);
}
void solve(){
    int n ,k ;cin >> n >> k;
    arr.resize(n);
    for(auto &inp : arr)cin >> inp;
    debug(arr);
    vector < int > ans;
    int lol = 0;
    for(int len = 1;len*k <= n ;len++){
        vector < int > dp(n,0);
        for(int j = len;j<n;j++)dp[j] = 1;
        for(int j = 2*len-1;j<n;j++){
            dp[j] += dp[j-2*len+1] * Is_same(j-2*len+1,j);
        }
        debug(len , dp);
        int mpos = max_element(dp.begin(),dp.end())-dp.begin();
        vector < int > locarr;
        for(int j = mpos-len+1;j<=mpos;j++)locarr.push_back(arr[j]);
        debug(locarr , mpos);
        if(lol < mpos){
            ans = locarr;
            lol = mpos;
        }
    }
    if(lol < k){
        cout << "-1" << endl;
        return;
    }
    cout << (int)ans.size() << endl;
    for(auto itr : ans)cout << itr << " ";
    cout << endl;
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt=1;
 //   cin >> tt;
    while(tt--)solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Sequence doesn't repeat k times
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -