제출 #746464

#제출 시각아이디문제언어결과실행 시간메모리
746464sword060Lampice (COCI21_lampice)C++17
50 / 50
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0);cin.tie(0); int x,k;cin>>x>>k; int a[x+1],mx=-1e9,l=1,r=1; for(int i=1;i<=x;i++)cin>>a[i]; for(int i=1;i<=x;i++){ for(int j=i;j<=x;j++){ int p=j-i+1; for(int s=p-1;s>=1;s--){ if(p%s||p/s<k)continue; bool f=1; for(int z=i+s;z<=j;z++) f&=(a[z]==a[z-s]); if(f){ if(mx<s){ mx=s;l=i;r=i+s-1; } break; } } } } if(mx==-1e9){ cout<<-1; return 0; } cout<<mx<<"\n"; for(int i=l;i<=r;i++)cout<<a[i]<<" "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...