結果
| 問題 | No.2715 Unique Chimatagram | 
| コンテスト | |
| ユーザー |  沙耶花 | 
| 提出日時 | 2024-04-05 21:29:49 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 958 ms / 2,000 ms | 
| コード長 | 814 bytes | 
| コンパイル時間 | 4,466 ms | 
| コンパイル使用メモリ | 253,544 KB | 
| 最終ジャッジ日時 | 2025-02-20 20:52:21 | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 40 | 
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
	
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	
	int n;
	cin>>n;
	vector<string> s(n);
	vector<vector<int>> c(n,vector<int>(26));
	rep(i,n){
		cin>>s[i];
		rep(j,s[i].size())c[i][s[i][j]-'a']++;
	}
	
	rep(i,n){
		rep(j,26){
			vector t = c[i];
			t[j]++;
			int c2 = 0;
			rep(k,n){
				if(i==k)continue;
				int cc = 0;
				rep(l,26){
					if(c[k][l]+1==t[l])cc++;
					else if(c[k][l]!=t[l])cc = 2;
				}
				if(cc==1)c2 ++;
			}
			if(c2==0){
				cout<<s[i] + string(1,'a'+j)<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}
            
            
            
        