結果

問題 No.587 七対子
ユーザー aitdccd
提出日時 2018-01-07 00:22:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 168,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 19:49:39
合計ジャッジ時間 2,628 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:29:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   29 |         cout << ans << endl;
      |                 ^~~
main.cpp:15:10: note: 'ans' was declared here
   15 |     char ans;
      |          ^~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

int main() {
    string s;
    cin >> s;

    vector<int> cnt(26);
    REP(i, s.size()) cnt[s[i] - 'a']++;

    int one = 0, two = 0;
    char ans;
    REP(i, 26) {
        switch (cnt[i]) {
            case 1:
                one++;
                ans = (char) i+'a';
                break;
            case 2:
                two++;
                break;
        }
    }

    if (one == 1 && two == 6) {
        cout << ans << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}
0