답안 #697455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -