結果
問題 |
No.548 国士無双
|
ユーザー |
![]() |
提出日時 | 2017-07-28 22:33:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 816 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 64,484 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-17 12:59:34 |
合計ジャッジ時間 | 1,128 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <algorithm> #include <cstdlib> #include <iostream> #include <vector> #include <math.h> using namespace std; #define int long long signed main() { string s; cin >> s; int cnt[13]; for (int i = 0; i < 13; i++) { cnt[i] = 0; } bool f = true; for (int i = 0; i < 13; i++) { if ((int)(s[i] - 'a') < 13) { cnt[(int)(s[i] - 'a')]++; }else{ f = false; } } int c = 0; for (int i = 0; i < 13; i++) { if (cnt[i] == 3) { f = true; } if (cnt[i] == 0) { c++; } } if (!f || (c >= 2)) { cout << "Impossible" << endl; } else { int x = -1; for (int i = 0; i < 13; i++) { if (cnt[i] == 0) { x = i; } } if (x == -1) { for (int i = 0; i < 13; i++) { cout << (char)('a' + i) << endl; } } else { cout << (char)('a' + x) << endl; } } return 0; }