結果

問題 No.548 国士無双
ユーザー YamaKasa
提出日時 2019-05-25 00:02:49
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 167,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-17 14:57:54
合計ジャッジ時間 1,937 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int c[13]{};
  string s;
  cin >> s;
  for (int i = 0; i < 13; i++) {
    c[s[i] - 'a']++;
  }
  bool flag = true;
  int k = 0;
  for (int i : c) {
    if (i > 2) {
      cout << "Impossible\n";
      return 0;
    }
    if (i == 2) {
      flag = false;
      if (k == 1) {
        cout << "Impossible\n";
        return 0;
      }
      k++;
    }
  }
  if (flag) {
    for (int i = 0; i < 13; i++) {
      cout << (char)(i + 'a') << "\n";
    }
  } else {
    for (int i = 0; i < 13; i++) {
      if (c[i] == 0) {
        cout << (char)(i + 'a') << "\n";
      }
    }
  }
  
  return 0;
}
0