当前位置: 代码迷 >> 综合 >> Compound Words UVA - 10391
  详细解决方案

Compound Words UVA - 10391

热度:39   发布时间:2023-10-13 14:44:10.0

问题类型: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;
}
  相关解决方案