結果

問題 No.548 国士無双
コンテスト
ユーザー ikd
提出日時 2017-07-28 23:05:23
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 359µs
コード長 618 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 374 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-29 14:35:45
合計ジャッジ時間 1,716 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
#define repeat(i,n)for(int i=0;i<(n);i++)

int main(){

   string S;
   cin>> S;

   vector<int> cnt(26, 0);
   vector<int> v;
   for(char c: S) cnt[c-'a']++;
   for(int i=0; i<='m'-'a'; i++){
      cnt[i]++;
      int c1=0, c2=0;
      for(int j=0; j<='m'-'a'; j++){
         c1+=cnt[j]==1;
         c2+=cnt[j]==2;
      }
      if(c1==12 and c2==1){
         v.push_back((char)(i+'a'));
      }
      cnt[i]--;
   }

   if(v.empty()){
      cout<< "Impossible"<< endl;
   }else{
      for(char e: v) cout<< e<< endl;
   }

   return 0;
}
0