这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上;

#include<bits/stdc++.h>
using namespace std;
map<string,int>MAP;
char s[120005][30];

int main(){
    MAP.clear();
   int n = 0;
   while(cin>>s[n]){

    MAP[s[n]]=1;
    n++;
   }
    for(int i=0;i<n;i++){
        int l=strlen(s[i]);

        for(int j= 0;j<l;j++){
        char temp1[30] = {'\0'};
        char temp2[30] = {'\0'};
            strncpy(temp1,s[i],j);
            strncpy(temp2,s[i]+j,l-j);
            if(MAP[temp1]&&MAP[temp2])
                {cout<<s[i]<<endl;
                break;}
        }

    }
return 0;


}

 

相关文章:

  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
猜你喜欢
  • 2021-08-18
  • 2021-11-23
  • 2021-12-27
  • 2022-12-23
  • 2021-09-27
  • 2021-07-29
相关资源
相似解决方案