結果

問題 No.548 国士無双
ユーザー Elk
提出日時 2018-06-30 01:29:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 901 bytes
コンパイル時間 1,822 ms
コンパイル使用メモリ 176,460 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 20:34:02
合計ジャッジ時間 2,655 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:17: warning: 'tmp' may be used uninitialized [-Wmaybe-uninitialized]
   33 |         cout << tmp << endl;
      |                 ^~~
main.cpp:9:22: note: 'tmp' was declared here
    9 |     char daburi = 0, tmp;
      |                      ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    map <char, int> mp;
    string str;
    string abc = "abcdefghijklm";
    int cnt = 0;
    char daburi = 0, tmp;

    cin >> str;
    sort(str.begin(), str.end());
    for(int i = 0; i < 13; i++){
        if(str[i] != abc[i]){
            tmp = abc[i];
            break;
        }
    }

    for(int i = 0; i < str.size(); i++){
        mp[str[i]]++;
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second != 0){
            cnt++;
        }
        if(itr->second == 2){
            daburi = itr->first;
        }
    }

    if(daburi != 0 && cnt == 12){
        cout << tmp << endl;
    }else if(daburi == 0 && cnt == 13){
        for(auto itr = mp.begin(); itr != mp.end(); itr++){
            cout << itr->first << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}
0