Submission #697455

# Submission time Handle Problem Language Result Execution time Memory
697455 2023-02-09T22:55:25 Z delrey Lampice (COCI21_lampice) C++14
0 / 50
1 ms 300 KB
#include <iostream>

using namespace std;

int n, k, a[50];

int main()
{
    cin>>n>>k;
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int b = 0; b < n; b++)
    {
        for(int i = 1; b + i * k < n; i++)
        {
            int patterns = 1;
            for(int j = 1; j < k; j++)
            {
                bool matches = true;
                for(int t = 0; t < i; t++)
                    if(a[b + t] != a[b + j * i + t])
                    {
                        matches = false;
                        break;
                    }
                if(!matches)
                    break;
                patterns++;
            }
            if(patterns == k)
            {
                cout<<i<<endl;
                for(int t = 0; t < i; t++)
                    cout<<a[b + t]<<" ";
                return 0;
            }

        }
    }
    cout<<-1<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -