結果

問題 No.548 国士無双
ユーザー ミドリムシミドリムシ
提出日時 2017-10-23 00:25:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 57,252 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 16:23:13
合計ジャッジ時間 1,373 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:10: warning: ‘nothing_alphabet’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |     char nothing_alphabet;
      |          ^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
using namespace std;

int main(){
    string S;
    cin >> S;
    char alphabets[13] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'};
    int alphabets_have[13];
    for(int i = 0; i < 13; i++){
        alphabets_have[i] = 0;
    }
    for(int i = 0; i < 13; i++){
        for(int j = 0; j < 13; j++){
            if(alphabets[j] == S[i]){
                alphabets_have[j]++;
                break;
            }
        }
    }
    bool have_no = false;
    bool have_2 = false;
    char nothing_alphabet;
    for(int i = 0; i < 13; i++){
        if(!alphabets_have[i]){
            if(!have_no){
                have_no = true;
                nothing_alphabet = alphabets[i];
            }else{
                cout << "Impossible" << endl;
                return 0;
            }
        }else if(alphabets_have[i] == 2){
            have_2 = true;
        }
    }
    if(have_no && have_2){
        cout << nothing_alphabet << endl;
    }else if(!have_no && !have_2){
        for(int i = 0; i < 13; i++){
            cout << alphabets[i] << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }
}
0