Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int n = 0;
  8.     cin >> n;
  9.    
  10.     for(int i=0; i<n; i++) {
  11.         string word;
  12.         cin >> word;
  13.        
  14.         set<string> substrings;
  15.        
  16.         for(int pos=0; pos<word.length(); pos++) {
  17.             for(int length=1; length<word.length()-pos+1; length++) {
  18.                 string substr = word.substr(pos, length);
  19.                
  20.                 if(substrings.count( substr ) == 0) {
  21.                     substrings.insert( substr );
  22.                 }
  23.             }
  24.         }
  25.        
  26.         cout << substrings.size() + 1 << endl;
  27.        
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement