Submission #798998

#TimeUsernameProblemLanguageResultExecution timeMemory
798998Tunglam07Lampice (COCI21_lampice)C++17
50 / 50
1 ms320 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, a[51]; bool ck=0; cin >> n >> m; if(m == 1) { cin >> a[0]; cout << 1 << endl; cout << a[0]; } else { for(int i = 1; i <= n; i++) { cin >> a[i]; } int num=n/m; for(int i = 1; i <= num; i++) { int num1 = n-m*i+1; for(int j = 1; j <= n-m*i+1; j++) { ck = 0; for(int k = 0; k < m - 1; k++) { for(int z = 0; z < i; z++) { if(a[j + z + k * i] != a[j + z + (k + 1) * i]) { ck = 1; } } } if(!ck) { cout << i << endl; for(int z = 0; z < i; z++) { cout << a[j + z] << " "; } return 0; } } } cout << -1; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:26:8: warning: unused variable 'num1' [-Wunused-variable]
   26 |    int num1 = n-m*i+1;
      |        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...