結果
| 問題 | No.548 国士無双 |
| コンテスト | |
| ユーザー |
dsytk7
|
| 提出日時 | 2017-07-28 22:30:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,209 bytes |
| コンパイル時間 | 1,057 ms |
| コンパイル使用メモリ | 159,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 12:58:31 |
| 合計ジャッジ時間 | 1,699 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< int, int >;
string t = "abcdfgjhijklm";
int a[14];
int main() {
string s;
cin >> s;
rep(i, s.size()) {
if ('a' <= s[i] and s[i] <= 'm') {
a[s[i]-'a']++;
}
else {
cout << "Impossible" << endl;
return 0;
}
}
bool two=false;
bool zero=false;
bool ok=true;
rep(i, 13) {
if (a[i] == 2) {
if (!two) { two = true; }
else { ok = false; break; }
}
else if (a[i] == 0) {
if (!zero) { zero = true; }
else { ok = false; break; }
}
else if (a[i] > 2) {
ok = false;
break;
}
}
if (!ok) { cout << "Impossible" << endl; }
else {
if (zero) {
rep(i, 13) {
if (a[i] == 0) {
cout << char('a' + i) << endl;
return 0;
}
}
}
else {
rep(i, 13) {
cout << char('a'+i) << endl;
}
}
}
}
dsytk7