結果
問題 |
No.2715 Unique Chimatagram
|
ユーザー |
![]() |
提出日時 | 2025-01-15 17:11:17 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 1,841 bytes |
コンパイル時間 | 4,018 ms |
コンパイル使用メモリ | 303,188 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-15 17:11:24 |
合計ジャッジ時間 | 6,539 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#ifdef t9unkubj #include"debug.cpp" //#include"template_no_debug.h" #else #define dbg(...) 199958 #endif #undef _GLIBCXX_DEBUG #pragma GCC optimize("O3") using namespace std; #include<bits/stdc++.h> using ll=long long; using ull=unsigned long long; template<class T>using vc=vector<T>; template<class T>using vvc=vc<vc<T>>; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++) #define DREP(i,n,m) for(ll i=(n);i>=(m);i--) #define drep(i,n) for(ll i=((n)-1);i>=0;i--) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() template<class T,class F> bool chmin(T &x, F y){ if(x>y){ x=y; return true; } return false; } template<class T, class F> bool chmax(T &x, F y){ if(x<y){ x=y; return true; } return false; } double pass_time=0; void solve(){ int n; cin>>n; using S=array<int,26>; map<S,int>cnt; rep(i,n){ string s; cin>>s; S res{}; rep(j,s.size())res[s[j]-'a']++; cnt[res]++; } for(auto&[x,y]:cnt){ int ok=0; auto T=x; rep(j,26){ { T[j]++; int C=0; rep(k,26){ if(!T[k])continue; T[k]--; if(cnt.count(T))C+=cnt[T]; T[k]++; } assert(C); if(C==1){ rep(i,26)rep(j,T[i])cout<<char(i+'a'); cout<<endl; return; } T[j]--; } } } cout<<"-1\n"; } signed main(){ cin.tie(0)->sync_with_stdio(0); pass_time=clock(); int t=1; //cin>>t; while(t--)solve(); pass_time=clock()-pass_time; dbg(pass_time/CLOCKS_PER_SEC); }