結果

問題 No.587 七対子
ユーザー take000
提出日時 2020-09-19 02:22:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 4,094 ms
コンパイル使用メモリ 192,340 KB
最終ジャッジ日時 2025-01-14 18:32:40
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
   18 |     char ans;
      |          ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

int main() {
    string s, t;
    cin >> s;
    t = s;

    int cnt[26] = {0};

    rep(i, s.size()) {
        cnt[s[i] - 'a']++;
    }

    bool flag = true;
    char ans;
    int one = 0;
    rep(i, 26) {
        if (cnt[i] == 1) {
            ans = 'a' + i;
            one++;
        }
        if (one >= 2 || cnt[i] >= 3) {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << ans;
    else
        cout << "Impossible";
    cout << endl;

    return 0;
}
0