답안 #638822

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638822 2022-09-07T14:58:13 Z NotLinux Lampice (COCI21_lampice) C++14
25 / 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,1LL);
        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 0 ms 212 KB Output is correct
8 Correct 0 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 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 1 ms 212 KB Output is correct
6 Correct 1 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
8 Correct 0 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 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Incorrect 0 ms 212 KB Output isn't correct
28 Halted 0 ms 0 KB -