10391 - Compound Words (UVA)

题目链接如下:

Online Judge

代码如下:

cpp 复制代码
#include <iostream>
#include <string>
#include <vector>
#include <set>
// #define debug

int main(){
    #ifdef debug
    freopen("0.txt", "r", stdin);
    freopen("1.txt", "w", stdout);
    #endif
    std::string word;
    std::vector<std::string> vec;
    std::set<std::string> st;
    while (std::cin >> word){
        vec.push_back(word);
        st.insert(word);
    }
    for (int i = 0; i < vec.size(); ++i){
        for (int j = 1; j < vec[i].size(); ++j){
            if(st.count(vec[i].substr(0, j)) && st.count(vec[i].substr(j))){
                std::cout << vec[i] << std::endl;
                break;
            }
        }
    }
    #ifdef debug
    fclose(stdin);
    fclose(stdout);
    #endif
    return 0;
}
相关推荐
naturerun4 分钟前
螺旋形遍历奇数阶矩阵
c++·算法·矩阵
郝学胜-神的一滴1 小时前
[简化版 GAMES 101] 计算机图形学 08:三角形光栅化上
c++·unity·游戏引擎·godot·图形渲染·opengl·unreal
佳xuan1 小时前
简而言之c++
c++·算法
屯子来了1 小时前
Windows + VS2022 + UE5.2 编译 Fast DDS 2.14.0 完整记录
c++·ue5·fastdds
顶点多余2 小时前
自定义协议、序列化、反序列化实现
java·linux·开发语言·c++·tcp/ip
Bruce_kaizy2 小时前
c++ linux环境编程——从应用层到linux内核深入了解文件io的调用机制(爆肝)
linux·c++·c·嵌入式linux·文件io
z200509302 小时前
C++中的右值引用
开发语言·c++
代码中介商2 小时前
C++文件流操作全解析
开发语言·c++
会周易的程序员3 小时前
aiDgeScanner架构与实现
c++·ide·物联网·架构·node.js·aiot
王老师青少年编程3 小时前
csp信奥赛C++高频考点专项训练之字符串 --【字符串排序】:生日
c++·字符串·csp·高频考点·信奥赛·生日·字符串排序