結果
| 問題 |
No.548 国士無双
|
| ユーザー |
sekiya9311
|
| 提出日時 | 2017-07-28 22:27:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 1,312 ms |
| コンパイル使用メモリ | 170,936 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 12:56:59 |
| 合計ジャッジ時間 | 1,958 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
string S;
int cnt[30];
int main() {
cin >> S;
bool f = false;
for (char c = 'a'; c <= 'm'; c++) {
string s = S + c;
sort(s.begin(), s.end());
memset(cnt, 0, sizeof(cnt));
for (char cc : s) cnt[cc - 'a']++;
bool ok = false;
for (char cc = 'a'; cc <= 'm'; cc++) {
if (cnt[cc - 'a'] == 0) {
ok = false;
break;
} else if (cnt[cc - 'a'] == 2) {
if (ok) {
ok = false;
break;
} else {
ok = true;
}
}
}
if (ok) {
cout << c << endl;
f = true;
}
}
if (!f) cout << "Impossible" << endl;
}
sekiya9311