結果
| 問題 |
No.2715 Unique Chimatagram
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-17 14:23:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 1,437 bytes |
| コンパイル時間 | 2,816 ms |
| コンパイル使用メモリ | 223,064 KB |
| 最終ジャッジ日時 | 2025-02-21 02:50:24 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rev(i, n) for (int i = (n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
void YesNo(bool f) {cout << (f ? "Yes\n" : "No\n");};
void fast_io() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
}
signed main(void) {
fast_io();
int N;
cin >> N;
vector<string> S(N);
rep(i, N) {
string s;
cin >> s;
sort(all(s));
S[i] = s;
}
unordered_set<int> st;
rep(i, N) {
rep(j, N) {
if (i == j) continue;
if (S[i] == S[j]) {
st.insert(i);
st.insert(j);
}
}
}
for (char c = 'a'; c <= 'z'; c++) {
rep(i, N) {
if (st.count(i)) continue;
string T = S[i] + c;
sort(all(T));
bool ok = true;
rep(j, N) {
if (i == j) continue;
for (char d = 'a'; d <= 'z'; d++) {
string U = S[j] + d;
sort(all(U));
if (T == U) {
ok = false;
break;
}
}
}
if (ok) {
cout << T << endl;
return 0;
}
}
}
cout << -1 << endl;
return 0;
}