結果
| 問題 | No.548 国士無双 |
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-02 22:00:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,081 bytes |
| コンパイル時間 | 590 ms |
| コンパイル使用メモリ | 77,120 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 14:44:57 |
| 合計ジャッジ時間 | 1,175 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
// No.548 国士無双
// https://yukicoder.me/problems/no/548
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<char> solve(string &S);
int main() {
cin.tie(nullptr);
string S;
cin >> S;
vector<char> ans = solve(S);
if (ans.empty())
cout << "Impossible" << endl;
else {
for (auto a: ans)
cout << a << endl;
}
}
vector<char> solve(string &S) {
vector<char> ans;
vector<char> candidates {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm'};
for (char c: candidates) {
string T = S + c;
vector<int> count(13, 0);
bool match = true;
for (char t: T) {
if ('a' <= t && t <= 'm')
count[t-'a']++;
else {
match = false;
break;
}
}
if (*max_element(count.begin(), count.end()) > 2 || *min_element(count.begin(), count.end()) < 1)
match = false;
if (match)
ans.push_back(c);
}
return ans;
}
kichirb3