답안 #638823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638823 2022-09-07T14:59:23 Z NotLinux Lampice (COCI21_lampice) C++14
10 / 50
1 ms 212 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]);
    }
    return (v1 == v2);
}
void solve(){
    int n ,k ;cin >> n >> k;
    arr.resize(n);
    for(auto &inp : arr)cin >> inp;
    vector < int > ans;
    int lol = 0;
    for(int len = 1;len*k <= n ;len++){
        vector < int > dp(n,0LL);
        for(int j = len-1;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);
        }
        int mpos = *max_element(dp.begin()+len,dp.end());
        int mindpos = max_element(dp.begin()+len,dp.end()) - dp.begin();
        vector < int > locarr;
        for(int j = mindpos-len+1;j<=mindpos;j++)locarr.push_back(arr[j]);
        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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -