結果

問題 No.548 国士無双
コンテスト
ユーザー focus
提出日時 2018-02-13 20:04:58
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 385 ms
コンパイル使用メモリ 78,280 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-27 06:07:17
合計ジャッジ時間 1,073 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:36:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   36 |         cout << ans << endl;
      |                 ^~~
main.cpp:8:10: note: 'ans' was declared here
    8 |     char ans;
      |          ^~~

ソースコード

diff #
raw source code

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int table[26] = {},flag=0,flag2=0;
    char ans;
    string str;
    cin >> str;
    for(int i=0;str[i]!='\0';i++){
        table[str[i]-'a']++;
    }
    for(int i=0;i<13;i++){
        if(table[i]==0){
             ans = i+'a';
             flag2++;
        }
        else if(table[i]==2) flag++;
        else if(flag2>1||flag>1||table[i]>2){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    for(int i=13;i<26;i++){
        if(table[i]){
            cout << "Impossible" << endl;
            return 0;
        }
    }
    if(flag==0&&flag2==1) cout << "Impossible" << endl;
    if(flag==0){
        for(int i=0;i<26;i++)   cout << 'a'+i << endl;
    }
    else{
        cout << ans << endl;
    }
    return 0;
}
0