Algorithm/백준

C++ 알고리즘 - 백준 11478 서로 다른 부분 문자열의 개수

마루설아 2025. 1. 11. 22:43

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

 

#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(void) {
	CPP_INIT();

	string str;
	int n, m, size;
	unordered_map<string, int> um;

	cin >> str;

	for (int i = 0; i < str.size(); i++) {
		for (int j = i; j < str.size(); j++) {
			um[str.substr(i, j - i + 1)]++;
		}
	}

	cout << um.size();
}