結果

問題 No.2715 Unique Chimatagram
ユーザー futamegawafutamegawa
提出日時 2024-04-05 22:04:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,309 bytes
コンパイル時間 4,007 ms
コンパイル使用メモリ 261,628 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:05:10
合計ジャッジ時間 31,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 169 ms
6,676 KB
testcase_09 AC 193 ms
6,676 KB
testcase_10 AC 192 ms
6,676 KB
testcase_11 AC 224 ms
6,676 KB
testcase_12 AC 182 ms
6,676 KB
testcase_13 AC 197 ms
6,676 KB
testcase_14 AC 166 ms
6,676 KB
testcase_15 AC 188 ms
6,676 KB
testcase_16 AC 169 ms
6,676 KB
testcase_17 AC 211 ms
6,676 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 746 ms
6,676 KB
testcase_40 WA -
testcase_41 AC 180 ms
6,676 KB
testcase_42 AC 5 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using llu = long long unsigned;

// メイン関数
int main() {
    int n;
    cin >> n;

    vector<string> s(n);
    for (int i=0; i<n; ++i) {
        string t;
        cin >> t;
        sort(t.begin(), t.end());
        s[i] = t;
    }

    vector<bool> isNg(n);
    for (int i=0; i<n; ++i) {
        for (int j=i+1; j<n; ++j) {
            if (s[i] == s[j]) {
                isNg[i] = true;
                isNg[j] = true;
            }
            else if (s[i].size() == s[j].size()) {
                map<char, int> tmp1, tmp2;
                for (int k=0; k<s[i].size(); ++k) {
                    tmp1[s[i][k]]++;
                }
                for (int k=0; k<s[j].size(); ++k) {
                    tmp2[s[j][k]]++;
                }
                int count = 0;
                for (char c='a'; c<='z'; ++c) {
                    if (tmp1[c] != tmp2[c]) { count++; }
                }
                if (count <= 2) {
                    isNg[i] = true;
                    isNg[j] = true;
                }
            }
        }
    }

    string ret = "-1";
    for (int i=0; i<n; ++i) {
        if (!isNg[i]) {
            ret = s[i] + 'a';
            break;
        }
    }

    cout << ret << endl; return 0;
}
0