結果

問題 No.548 国士無双
ユーザー ikd
提出日時 2017-07-28 23:05:23
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 64,820 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 13:30:00
合計ジャッジ時間 1,179 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#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