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;
}
相关推荐
用户3900341061489 小时前
new 到底做了什么:operator new、malloc、delete[] 的完整调用链
c++
wuminyu11 小时前
OpenJDK学习笔记:Native事件队列与Java回调背压
java·linux·c语言·jvm·c++
guizhoumen13 小时前
PageAdmin开源网站无障碍/适老化工具条插件-让网站“看得清、听得懂“
c++·mfc
Chen_harmony14 小时前
十六、ALV树
开发语言·c++
西西弗Sisyphus14 小时前
C++ 最小 Agentic Loop 实现 - 回调函数系列 - 初识回调(5)
开发语言·c++
爱写代码的小朋友15 小时前
C++ 信息学奥赛入门教程-从零基础到通过 CSP-J 第二轮的十八堂课
c++
小灰灰搞电子15 小时前
C/C++ 的大小端是什么?一个整数在内存里究竟怎么存储?
c语言·arm开发·c++
船神丿男人16 小时前
从爬楼梯到最小路径和:6 道 C++ 动态规划题的状态设计
开发语言·c++·动态规划
今天要早睡_18 小时前
C++15_deque与容器适配器复习
java·c++·rpc
@三十一Y19 小时前
C++高阶数据结构:图
开发语言·数据结构·c++