結果
問題 |
No.2715 Unique Chimatagram
|
ユーザー |
|
提出日時 | 2024-04-06 14:53:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 650 bytes |
コンパイル時間 | 3,607 ms |
コンパイル使用メモリ | 270,372 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-01 03:51:57 |
合計ジャッジ時間 | 10,199 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 3 WA * 37 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n;cin>>n; map<vector<int>,int>mp; map<string,int>cnt; vector<string>s(n);for(int i=0;i<n;i++)cin>>s[i]; string ans; for(int i=0;i<n;i++){ auto ns=s[i]; cnt[ns]++; vector<int>now(26); for(char c:ns)now[c-'a']++; if(mp[now]==0)ans=ns; mp[now]++; } if(mp.size()==1 and n!=1){ cout<<-1<<endl;return 0; }else if(n==1){ cout<<s[0]<<endl; }else{ sort(ans.begin(),ans.end()); do{ if(cnt[ans]==0)cout<<ans<<endl; return 0; }while(next_permutation(ans.begin(),ans.end())); } }