結果
| 問題 |
No.587 七対子
|
| コンテスト | |
| ユーザー |
m1025o1184t
|
| 提出日時 | 2019-12-02 04:26:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 627 bytes |
| コンパイル時間 | 1,710 ms |
| コンパイル使用メモリ | 176,032 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-19 20:02:02 |
| 合計ジャッジ時間 | 2,924 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string S;
cin >> S;
sort(all(S));
string T = S;
auto result = unique(all(T));
T.erase(result, T.end());
bool elf = true;
if ((S.size() + 1) / 2 != T.size()) elf = false;
priority_queue<char> que;
que.push('+');
rep(i, S.size()) {
if (que.top() != S[i]) {
que.push(S[i]);
}
else {
que.pop();
}
}
if (que.size() == 2 && elf) cout << que.top() << endl;
else cout << "Impossible" << endl;
return 0;
}
m1025o1184t