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;
}
相关推荐
Darkwanderor1 小时前
Linux系统编程实战项目:模拟实现shell
linux·c++
himobrinehacken2 小时前
揭秘Windows程序启动的神秘之旅
c++·安全
库玛西2 小时前
C++ 运行时多态 :核心总结与原理图解
c语言·c++·笔记
Byron Loong3 小时前
【C++】重定向是什么
开发语言·c++
hansang_IR4 小时前
【题解】LC:Z 算法(Z Algorithm)
c++·算法·字符串
霍霍的袁5 小时前
【C++】模板从入门到进阶(函数模板 + 类模板 + 特化 + 分离编译)
开发语言·c++·visual studio
海清河晏1116 小时前
Qt 实战:信号与槽+事件系统
开发语言·c++·qt
hansang_IR6 小时前
【题解】LC:卷积(Convolution (Mod 1,000,000,007))
c++·算法·ntt·crt
计算机内卷的N天6 小时前
三维C三维配准软件(术中CT)
c++·c臂三维配准
啦啦啦啦啦zzzz6 小时前
设计模式:原型模式
c++·设计模式·原型模式