Submission #874911

#TimeUsernameProblemLanguageResultExecution timeMemory
874911tsumondaiLampice (COCI21_lampice)C++14
50 / 50
1 ms600 KiB
#include <iostream> #include <cstdio> using namespace std; const int N=55; int n, k; int p[N]; int main() { scanf("%d %d", &n, &k); for (int i=0; i<n; ++i) scanf("%d", &p[i]); for (int l=0; l<n; ++l) { for (int r=l; r<n; ++r) { int ok=1, d=r-l+1; for (int i=1; i<k && ok; ++i) { for (int j=l; j<=r; ++j) { if (j+i*d>=n || p[j+i*d]!=p[j]) { ok=0; break; } } } if (ok) { printf("%d\n", r-l+1); for (int i=l; i<=r; ++i) printf("%d ", p[i]); return 0; } } } printf("-1"); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:13:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     for (int i=0; i<n; ++i) scanf("%d", &p[i]);
      |                             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...