https://www.acmicpc.net/problem/16172

 

16172번: 나는 친구가 적다 (Large)

첫 번째 줄에는 알파벳 소문자, 대문자, 숫자로 이루어진 문자열 S가 주어진다. (1 ≤ |S| ≤ 200,000) 두 번째 줄에는 성민이가 찾고자 하는 알파벳 소문자, 대문자로만 이루어진 키워드 문자열 K가

www.acmicpc.net

 

[난이도] Gold4
[유형] KMP,문자열

[풀이]
출제의도는 KMP인것 같은데 string::find를 이용해서 풀어도 시간내에 풀린다.

 

#include <iostream>
#include <string>
#include <cctype>
using namespace std;
string a,b,t;
int main(){
    cin >> t >> b;
    for(int i=0;i<t.size();i++){
        if(isalpha(t[i])) a.push_back(t[i]);
    }
    printf("%d",a.find(b) != string::npos);
}

 


https://github.com/has2/Problem-Solving/blob/master/boj-solved.ac/Gold4/16172.cpp

+ Recent posts