UVA 10391 stl
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1332
#include<iostream> #include<stdio.h> #include<string.h> #include<string> #include<map> using namespace std; string ss; char s[120003][60]; int main() { int i,j; i=0; map<string,int>Map; while(1) { gets(s[i]); if(strcmp(s[i],"")==0) break; int len=strlen(s[i]); ss=""; for(j=0;j<len;j++) { ss+=s[i][j]; } Map[ss]=1; i++; } int l=i; string s1,s2; for(i=0;i<l;i++) { s1=""; int fl=strlen(s[i]); for(j=0;j<fl;j++) { s1+=s[i][j]; s2=""; for(int k=j+1;k<fl;k++) { s2+=s[i][k]; } if(Map[s1]==1&&Map[s2]==1) { printf("%s\n",s[i]); break; } } } }