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;
}
相关推荐
wefg17 小时前
【项目】C++ 基于 Vibe Coding 的 OJ 平台
开发语言·c++
郝学胜-神的一滴14 小时前
Effective STL 条款 07:指针容器销毁前先删除
开发语言·c++·vscode·leetcode·rpc·visual studio
Lucas. Wáng17 小时前
Qt学习之旅
c++·qt
星恒随风17 小时前
从0实现C++ AI大模型接入SDK(二):AI知识科普——从图灵测试到ChatGPT,人工智能的发展历程
linux·c++·人工智能·笔记·chatgpt
青少儿编程课堂17 小时前
蓝桥杯真题解析:三维偏序的CDQ分治(全国青少年信息素养大赛与电子学会编程考级)
c++·python·算法·bfs·信息学竞赛
csdn_aspnet19 小时前
C++ 求给定点集的简单闭合路径(Find Simple Closed Path for a given set of points)
c++
艾莉丝努力练剑19 小时前
【AI接入大模型SDK】解决接口连接异常问题
前端·c++·人工智能·学习·ai·架构
Severus_black19 小时前
【C++初阶】模板进阶
c语言·c++·学习
艾莉丝努力练剑21 小时前
【AI接入大模型SDK】Markdown格式解析
前端·c++·人工智能·学习·ai·架构
逐光沧海21 小时前
数据结构-链表习题(C++)
数据结构·c++·链表