結果

問題 No.548 国士無双
ユーザー monman53
提出日時 2017-07-28 22:45:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,311 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 160,312 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 13:29:18
合計ジャッジ時間 1,744 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

// header {{{
// #define NDEBUG
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)        (abs((a)-(b)) < EPS)
#define CILING(a, b)    (((a)+(b)-1LL)/(b))

template<class T>
using PIT = pair<int, T>;
template<class T>
using PTI = pair<T, int>;
using PII = pair<int, int>;
using PDI = pair<double, int>;
using LL  = long long;
using ULL = unsigned long long;
// }}}

int main() {
    vector<int> count(13, 0);
    string s;cin >> s;
    for(int i=0;i<13;i++){
        count[s[i]-'a']++;
    }
    int ccount = 0;
    int count0 = 0;
    for(int i=0;i<13;i++){
        if(count[i] > 2){
            cout << "Impossible" << endl;
            return 0;
        }
        if(count[i] == 2){
            ccount++;
        }
        if(count[i] == 0){
            count0++;
        }
    }
    if(ccount > 1 || count0 > 1){
        cout << "Impossible" << endl;
        return 0;
    }
    if(ccount == 1){
        for(int i=0;i<13;i++){
            if(count[i] == 0){
                cout << char('a'+i) << endl;
                return 0;
            }
        }
    }
    for(int i=0;i<13;i++){
        cout << char('a'+i) << endl;
    }
    return 0;
}
0