結果
問題 | No.2715 Unique Chimatagram |
ユーザー |
![]() |
提出日時 | 2024-04-05 21:55:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,560 bytes |
コンパイル時間 | 3,413 ms |
コンパイル使用メモリ | 217,576 KB |
最終ジャッジ日時 | 2025-02-20 21:17:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 19 |
ソースコード
//#pragma GCC optimize("Ofast") //#pragma GCC optimize "O3,omit-frame-pointer,inline" #include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <utility> // pair, make_pair #include <tuple> // tuple, make_tuple #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <map> // map #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <deque> // deque #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <iomanip>//fixed,setprecision #include <limits.h>//INT_MAX #include <math.h>//M_PI #include <random> #include <regex> // 正規表現 #include <time.h> #include <fstream> #include <array> #include <bit> #include <chrono> #include <ranges> #include <span> #include <cmath> #include <cstdint> #include <complex>//複素数 //#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; //using mint = modint1000000007; //using mint = modint998244353; // using mint=modint; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) //const int dx[8]={1,0,-1,0,1,1,-1,-1}; //const int dy[8]={0,1,0,-1,1,-1,1,-1}; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; int main(){ int n; cin>>n; map<string,int>mp; vector<vector<int>>cnt(n,vector<int>(26)); string s; rep(i,n){ cin>>s; sort(s.begin(),s.end()); mp[s]++; rep(j,s.size()){ int num=s[j]-'a'; cnt[i][num]++; } } rep(i,n){ int sho=101010; rep(j,n){ if(i==j)continue; int sa=0; rep(k,26)if(cnt[i][k]!=cnt[j][k])sa+=abs(cnt[i][k]-cnt[j][k]); sho=min(sa,sho); //cerr<<sa<<" "<<sho<<endl; } if(sho!=0){ rep(k,26){ int ng=0; int sa=0; rep(j,n){ if(i==j)continue; if(cnt[i][k]+1==cnt[j][k])ng++; } if(ng==0){ rep(kk,26){ rep(l,cnt[i][kk])cout<<(char)('a'+kk); } cout<<(char)('a'+k)<<endl; return 0; } } return 0; } } cout<<-1<<endl; return 0; }