uva10391

//两重for遍历tle

//a alien born less lien never nevertheless new newborn the zebra

//60ms

#include <iostream>
#include <set>
#include <string>
using namespace std;
set<string> arr, ans;
int main()
{
 string t;
 while (cin >> t)
  arr.insert(t);
 set<string>::iterator it=arr.begin();
 for (it++;it != arr.end();it++)//第一个不必拆
 {
  string s = *it;
  int len = s.size();
  for (int j = 1;j < len;j++)
  {
   string s1 = s.substr(0, j), s2 = s.substr(j);
   if (arr.count(s1) && arr.count(s2)) { ans.insert(s); break; }
  }
 }
 for (it = ans.begin();it != ans.end();it++)
  cout << *it << endl;
 return 0;
}

原文地址:https://www.cnblogs.com/schsb/p/7806242.html