結果

問題 No.587 七対子
コンテスト
ユーザー 梧桐
提出日時 2026-03-22 17:24:55
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 667 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 718 ms
コンパイル使用メモリ 76,436 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-22 17:25:01
合計ジャッジ時間 1,270 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>

using namespace std;

int cnt[26], ans;
string s;

int main() {
    // freopen("pair.in", "r", stdin);
    // freopen("pair.out", "w", stdout);

    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        ++cnt[s[i] - 'a'];
    }

    for (int i = 0; i < 26; ++i) {
        if (cnt[i] == 1) {
            if (ans) {
                puts("Impossible");
                break;
            } else {
                ans = i;
            }
        } else if (cnt[i] > 2) {
            puts("Impossible");
            break;
        }
        if (i == 25) {
            printf("%c\n", ans + 'a');
        }
    }

    return 0;
}
0