結果

問題 No.2737 Compound Word
ユーザー cho435
提出日時 2024-04-16 02:01:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 197,472 KB
最終ジャッジ日時 2025-02-21 02:24:48
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    int ans = 0;
    vector<string> vs;
    auto check = [&](const string &s) {
        for(const string &v : vs) {
            if(v == s) {
                return 0;
            }
        }
        vs.emplace_back(s);
        return 1;
    };
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            if(i == j) continue;
            string s = S.at(i) + S.at(j);
            ans += check(s);
        }
    }
    cout << ans << endl;
}
0