Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<queue>
- #include<vector>
- #include<set>
- #include<cmath>
- #include <map>
- #include<math.h>
- #include<cstring>
- #include<string>
- typedef long double ld;
- typedef long long ll;
- using namespace std;
- vector<string> V;
- string a;
- map <string, int > pie;
- void calc( int x){
- if (x>=a.length())return;
- string cas;
- if (a.length() - x >= 2){
- //cout << cas << '\n';
- cas = a.substr(x, 3);
- reverse(cas.begin(), cas.end());
- if (pie[cas] != 0)
- {
- return;
- }
- if (cas.length()>1&&pie[cas]==0)
- V.push_back(cas);
- ++pie[cas];
- calc(x + 3);
- --pie[cas];
- }
- if (a.length() - x >= 1){
- cas = a.substr(x, 2);
- if (pie[cas] != 0)
- {
- return;
- }
- reverse(cas.begin(), cas.end());
- if (cas.length()>1 ) V.push_back(cas);
- ++pie[cas];
- calc(x + 2);
- --pie[cas];
- }
- else return;
- }
- int main(){
- cin >> a;
- if (a.length() == 5){
- cout << 0;
- return 0;
- }
- a.erase(0, 5);
- reverse(a.begin(), a.end());
- //cout << a << '\n';
- calc(0);
- sort(V.begin(), V.end());
- map<string,int> rep;
- vector<string > ans;
- for (int i = 0; i < V.size(); i++){
- if (rep[V[i]] == 0)ans.push_back(V[i]);
- ++rep[V[i]];
- }
- cout << ans.size()<<'\n';
- for (int i = 0; i < ans.size(); ++i){
- cout << ans[i] << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement