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;
}
相关推荐
「QT(C++)开发工程师」2 小时前
C++ std::move 详解
开发语言·c++
豆沙沙包?4 小时前
C++~~~set容器、map容器(p57-P69)
开发语言·c++
qeen875 小时前
【数据结构】哈希表的C++实现与封装
数据结构·c++·散列表·哈希表
乐观勇敢坚强的老彭6 小时前
C++信奥GESP四级的常见题型和解题模板速查表
开发语言·c++
欧特克_Glodon7 小时前
OpenCV计算机视觉开发入门与实践<二十二>:图像平滑之线性滤波
c++·人工智能·opencv·计算机视觉
沙盘客7 小时前
AFSIM 示例解读(09)· 传感器全家桶 sensor_demos(下):ESM / SAR / 被动测向
c++·经验分享·后端
大鹏的NLP博客7 小时前
WSL2 资源治理:从 ONNX Runtime CUDA 编译 OOM 到 `.wslconfig` 防御配置
c++·深度学习·onnx runtime
星星.7228 小时前
C++算法竞赛|二分查找与二分答案:边界模板、浮点二分、STL
数据结构·c++·算法
老当益壮梁奶奶8 小时前
Linux 软件编程学习笔记(六):线程编程入门与实践
linux·c语言·c++·笔记·学习
小小龙学IT8 小时前
Dear ImGui 开源即时模式 GUI 库深度解析
c++·ui·开源