Recent Posts
Notice
No Rules Rules
서로 다른 부분 문자열의 개수 (feat. 백준, 11478번) 본문
728x90
반응형
서로 다른 부분 문자열의 개수
https://www.acmicpc.net/problem/11478
반응형
// woohyeon.kim
// https://www.acmicpc.net/problem/11478
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
string S;
set<string> ans;
cin >> S;
register int size = S.size();
for (register int i = 0, j; i < size; ++i)
for (j = 0; j < size - i; ++j)
ans.insert(S.substr(j, i + 1));
cout << ans.size();
return 0;
}
// *&)*@*
입력받은 문자열에 대해서 문자열 1개부터 N개까지 각각을 자료구조 set으로 입력 받습니다. 중복된 경우, 하나의 문자열만을 갖기 위함입니다.
자료구조 set은 유일한 key를 갖고, 그렇기 때문에 중복된 key가 있더라도 하나의 key만을 갖게 됩니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
네 번째 점 (feat. 백준, 3009번) (0) | 2022.08.03 |
---|---|
직사각형에서 탈출 (feat. 백준, 1085번) (0) | 2022.08.03 |
대칭 차집합 (feat. 백준, 1269번) (0) | 2022.08.03 |
듣보잡 (feat. 백준, 1764번) (0) | 2022.08.03 |
숫자 카드 2 (feat. 백준, 10816번) (0) | 2022.08.03 |
Comments