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;
}
相关推荐
AA陈超25 分钟前
004 T02 - 俯视角摄像机系统 设计文档
网络·c++·ue5·虚幻引擎
bu_shuo33 分钟前
c与cpp中的argc和argv
c语言·c++·算法
蓝创精英团队39 分钟前
VCPKG 跨平台C++ 库管理器
c++·vcpkg
Jayden_Ruan2 小时前
C++组合的输出
c++·算法·深度优先
froyoisle3 小时前
CSP 真题解析:[CSP-J 2020-T3] 表达式
c++·算法·csp·信息学·信奥赛
Darkwanderor3 小时前
动、静态库相关内容的详细介绍
linux·c语言·开发语言·c++
文祐3 小时前
C++类之虚函数表没有虚继承的菱形继承
开发语言·c++·算法
孬甭_5 小时前
C++ string类
开发语言·c++
盐焗鹌鹑蛋5 小时前
【C++】C++11:右值引用、移动语义万能引用
c++
LingzhiPi5 小时前
零知ESP32--RC522NFC考勤打卡系统
c++·单片机·嵌入式硬件