結果
| 問題 | 
                            No.2715 Unique Chimatagram
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hiro71687k
                         | 
                    
| 提出日時 | 2024-11-04 12:06:13 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,343 bytes | 
| コンパイル時間 | 4,670 ms | 
| コンパイル使用メモリ | 261,892 KB | 
| 最終ジャッジ日時 | 2025-02-25 02:15:43 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 34 WA * 6 | 
ソースコード
#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(char c='a';c<='z';c++){
            bool ok=true;
            memo2[c]++;
        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(c);
            cout << s[i] << endl;
            return 0;
        }
        memo2[c]--;
        }
    }
    cout << -1 << endl;
}
            
            
            
        
            
hiro71687k