結果

問題 No.2737 Compound Word
ユーザー コーラ
提出日時 2024-05-04 13:28:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,047 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 77,140 KB
最終ジャッジ日時 2025-02-21 10:52:19
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 1 RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>

int main(void){
    
    //値の取得
    //-------------------------------
    int N{ 0 };
    std::cin >> N;
    std::vector<std::string> strs;
    
    for(int i{ 0 };i < N; ++i){
        std::string str;
        std::cin >> str;
        strs.push_back(str);
    }
    //-------------------------------
    
    //アルゴリズム
    //-------------------------------
    std::vector<std::string> catStrs;
    
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i != j){
                if(catStrs.empty()){
                    catStrs.push_back(strs[i]+strs[j]);
                }else{
                    for(const std::string& cs: catStrs){
                        if( cs != (strs[i]+strs[j]) ){
                            catStrs.push_back(strs[i]+strs[j]);
                        }
                    }
                }
            }
        }
    }
    //-------------------------------
    
    std::cout << catStrs.size() << std::endl;

}
0