結果
問題 | No.548 国士無双 |
ユーザー |
![]() |
提出日時 | 2017-07-30 13:11:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,804 bytes |
コンパイル時間 | 1,940 ms |
コンパイル使用メモリ | 183,556 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 13:41:05 |
合計ジャッジ時間 | 2,672 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ bool check(string s) { map<char, int> m; fore(c, s) m[c]++; vector<int> v; rep(j, 0, 13) if (m['a' + j]) v.push_back(m['a' + j]); sort(v.begin(), v.end()); if (v.size() != 13) return 0; int ok = 1; rep(i, 0, 12) if (v[i] != 1) ok = 0; if (v[12] != 2) ok = 0; if (ok) return 1; return 0; } //--------------------------------------------------------------------------------------------------- vector<char> solve(string S) { vector<char> ans; rep(i, 0, 13) { char c = 'a' + i; if (check(S + c)) ans.push_back(c); } return ans; } //--------------------------------------------------------------------------------------------------- void _main() { string S; cin >> S; auto ans = solve(S); if (ans.size() == 0) printf("Impossible\n"); else fore(i, ans) printf("%c\n", i); }