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
'Problem-Solving > BOJ' 카테고리의 다른 글
[BOJ/백준][Gold4] 3908 : 서로 다른 소수의 합 (C++) (0) | 2021.02.06 |
---|---|
[BOJ/백준][Gold4] 20040 : 사이클게임 (C++) (0) | 2021.02.06 |
[BOJ/백준][Gold4] 1322 : X와 K (C++) (0) | 2021.02.06 |
[BOJ/백준][Gold4] 9007 : 카누 선수 (C++) (0) | 2021.02.06 |
[BOJ/백준][Gold4] 3671 : 산업 스파이의 편지 (C++) (0) | 2021.01.31 |