Submission #557367

#TimeUsernameProblemLanguageResultExecution timeMemory
557367new_accLampice (COCI21_lampice)C++14
50 / 50
1 ms340 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod2=998244353; const ll mod=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; int t[N]; void solve(){ int n,k; cin>>n>>k; for(int i=1;i<=n;i++) cin>>t[i]; for(int i=1;i<=n;i++){ for(int i2=i;i2<=n;i2++){ if((i2-i+1)%k) continue; int dl=(i2-i+1)/k; bool ok=1; for(int xd=i+dl;xd<=i2;xd++) if(t[xd]!=t[xd-dl]) ok=0; if(ok){ cout<<dl<<"\n"; for(int xd=i;xd<i+dl;xd++) cout<<t[xd]<<" "; cout<<"\n"; return; } } } cout<<-1<<"\n"; } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); int tt=1; while(tt--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...