結果
問題 | No.2715 Unique Chimatagram |
ユーザー |
![]() |
提出日時 | 2024-04-05 23:22:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 817 bytes |
コンパイル時間 | 1,905 ms |
コンパイル使用メモリ | 181,496 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 03:06:15 |
合計ジャッジ時間 | 3,715 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {int N; cin >> N;string a = "abcdefghijklmnopqrstuvwxyz";vector<string> S(N);map<string, int> M;for (int i = 0; i < N; i++) {cin >> S.at(i);sort(S.at(i).begin(), S.at(i).end());M[S.at(i)]++;}for (pair<string, int> P : M) {if (P.second == 1) {for (int i = 0; i < 26; i++) {int Count = 0;string T = P.first + a.at(i);sort(T.begin(), T.end());for (int j = 0; j < N; j++) {for (int k = 0; k < 26; k++) {string U = S.at(j) + a.at(k);sort(U.begin(), U.end());if (T == U) Count++;}}if (Count == 1) {cout << T << endl;return 0;}}}}cout << -1 << endl;}