Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- int main() {
- int n = 0;
- cin >> n;
- for(int i=0; i<n; i++) {
- string word;
- cin >> word;
- set<string> substrings;
- for(int pos=0; pos<word.length(); pos++) {
- for(int length=1; length<word.length()-pos+1; length++) {
- string substr = word.substr(pos, length);
- if(substrings.count( substr ) == 0) {
- substrings.insert( substr );
- }
- }
- }
- cout << substrings.size() + 1 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement