Advertisement
999ms

Untitled

Mar 30th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4. using ld = long double;
  5.  
  6. map<pair<string,string>, int> mp;
  7.  
  8. int main(){  
  9.     ios_base::sync_with_stdio(false);
  10.     cin.tie(nullptr);
  11.     int t;
  12.     cin>>t;
  13.     set<string> st;
  14.     while(t--){
  15.         string s;
  16.         cin>>s;
  17.         int n = s.length();
  18.         string from = s.substr(0,3);
  19.         st.insert(from);
  20.         for(int i = 1;i<n-2;i++){
  21.             string to = s.substr(i,3);
  22.             st.insert(to);
  23.             mp[make_pair(from, to)]++;
  24.             from = to;
  25.         }
  26.     }
  27.     cout<<st.size()<<" "<<mp.size()<<endl;
  28.     for(auto p : mp){
  29.         cout<<p.first.first<<" "<<p.first.second<<" "<<p.second<<"\n";
  30.     }
  31.    
  32.     return 0;  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement