結果
| 問題 | No.587 七対子 | 
| コンテスト | |
| ユーザー |  kichirb3 | 
| 提出日時 | 2018-03-02 20:22:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 733 bytes | 
| コンパイル時間 | 704 ms | 
| コンパイル使用メモリ | 79,292 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 19:51:09 | 
| 合計ジャッジ時間 | 1,715 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
ソースコード
// No.587 七対子
// https://yukicoder.me/problems/no/587
//
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
string solve(string &S);
int main() {
    cin.tie(0);
    string S;
    cin >> S;
    string ans = solve(S);
    cout << ans << endl;
}
string solve(string &S) {
    unordered_map<char, int> char_count;
    for (char s: S)
        char_count[s]++;
    string ans = "";
    for (auto c: char_count) {
        if (c.second > 2) {
            ans = "Impossible";
            break;
        } else if (c.second == 1) {
            if (ans != "") {
                ans = "Impossible";
                break;
            }
            ans += c.first;
        }
    }
    return ans;
}
            
            
            
        