테스트케이스 중 딱 1개만 통과를 못 하고 있어서 도저히 찾질 못하겠네요 ㅠ
고수님들 도와주시면 감사하겠습니다 ㅠㅠ
#include<iostream>
using namespace std;
int K, M, N;
int* sec_code;
int* new_input;
void PrintList(int* arr, int size) {
for (int i=0; i<size; i++)
cout << arr[i] << " ";
cout << endl;
}
void check() {
bool start = false;
int code_chk_idx = 0;
// 패턴 사이즈 1
if (M == 1) {
for (int i=0; i<N; i++) {
if (sec_code[0] == new_input[i]) {
cout << "secret" << endl;
return;
}
}
cout << "normal" << endl;
return;
}
for (int i=0; i<N; i++) {
if (start) {
code_chk_idx++; // 다음 index로 이동
if (sec_code[code_chk_idx] != new_input[i]) {
// 틀림
start = false;
code_chk_idx = 0;
// 현재 인덱스부터 다시 확인
i--;
}
else {
if (code_chk_idx == M-1) {
cout << "secret" << endl;
return;
}
}
}
else {
// 첫 번째 숫자가 맞으면, 확인 시작
if (sec_code[0] == new_input[i])
start = true;
// 못 찾은 상태에서 문자열 수가 부족하면, 종료
if (i >= N-M+1) {
cout << "normal" << endl;
return;
}
}
}
}
int main(int argc, char** argv)
{
cin >> M >> N >> K;
// M : 비밀 메뉴 길이 (1~100)
// N : 새 입력 (1~100)
// K : 버튼의 갯수 1 ~ K (1~9)
sec_code = new int[M];
new_input = new int[N];
for (int i=0; i<M; i++)
cin >> sec_code[i];
for (int i=0; i<N; i++)
cin >> new_input[i];
if (N<M) {
cout << "normal" << endl;
return 0;
}
check();
return 0;
}