結果
問題 | No.2715 Unique Chimatagram |
ユーザー |
![]() |
提出日時 | 2024-11-04 12:02:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,229 bytes |
コンパイル時間 | 4,497 ms |
コンパイル使用メモリ | 260,628 KB |
最終ジャッジ日時 | 2025-02-25 02:14:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 19 |
ソースコード
#include <bits/stdc++.h> #include<atcoder/all> using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ll mod=998244353; ll inf=1000000000000000000; int main(){ ll n; cin >> n; vector<string>s(n); for (ll i = 0; i < n; i++) { cin >> s[i]; sort(s[i].begin(),s[i].end()); } for (ll i = 0; i < n; i++) { map<char,ll>memo,memo2; for (ll j = 0; j < s[i].size(); j++) { memo2[s[i][j]]++; } bool ok=true; for (ll j = 0; j < n; j++) { if (j==i) { continue; } memo=memo2; bool o=true; for (ll k = 0; k < s[j].size(); k++) { if (memo[s[j][k]]==0) { o=false; break; }else{ memo[s[j][k]]--; } } if (o) { ok=false; break; } } if (ok) { s[i].push_back('a'); cout << s[i] << endl; return 0; } } cout << -1 << endl; }