问题类型:STL-Map。
03pie’s solution for [UVA-10391]
题目链接
#include<iostream>
#include<cstring>
#include<map>using namespace std;map<string,int> words;
int main(){//freopen("F://inp.txt","r",stdin);string word;while(cin>>word){words[word]=word.size();}for(map<string,int>::iterator it=words.begin();it!=words.end();++it){int len=it->second;string a=it->first,left,right;if(len>1){for(int i=1;i<len;i++){string left=a.substr(0,i); string right=a.substr(i,len-i);if(words[left]&&words[right]){cout<<a<<"\n";break;}} }}return 0;
}