結果
| 問題 | No.2715 Unique Chimatagram | 
| コンテスト | |
| ユーザー |  Tatsu_mr | 
| 提出日時 | 2024-04-05 22:33:38 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,008 bytes | 
| コンパイル時間 | 2,230 ms | 
| コンパイル使用メモリ | 205,924 KB | 
| 最終ジャッジ日時 | 2025-02-20 21:47:34 | 
| ジャッジサーバーID (参考情報) | judge3 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 TLE * 1 -- * 14 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    set<string> st;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        st.insert(s[i]);
    }
    if (st.size() == 1) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        for (char c = 'a'; c <= 'z'; c++) {
            string t = s[i] + c;
            sort(t.begin(), t.end());
            bool ok = true;
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                for (char d = 'a'; d <= 'z'; d++) {
                    string u = s[j] + d;
                    sort(u.begin(), u.end());
                    if (t == u) {
                        ok = false;
                    }
                }
            }
            if (ok) {
                cout << t << endl;
                return 0;
            }
        }
    }
}
            
            
            
        