結果

問題 No.548 国士無双
ユーザー ikd
提出日時 2017-07-28 22:52:09
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 62,136 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-17 13:29:27
合計ジャッジ時間 1,124 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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);
for(char c: S) cnt[c-'a']++;
for(int i=0; i<='m'-'a'; i++)if(cnt[i]>=3){
cout<< "Impossible"<< endl;
return 0;
}
int _cnt2=0;
for(int i=0; i<='m'-'a'; i++) _cnt2+=cnt[i]==2;
if(_cnt2>1){
cout<< "Impossible"<< endl;
return 0;
}
int _cnt1=0;
for(int i=0; i<='m'-'a'; i++) _cnt1+=cnt[i]==1;
if(_cnt2==0){
if(_cnt1==S.size()){
for(int i=0; i<='m'-'a'; i++) cout<< (char)(i+'a')<< endl;
}else{
cout<< "Impossible"<< endl;
}
}else{
for(int i=0; i<='m'-'a'; i++)if(cnt[i]==0){
cout<< (char)(i+'a')<< endl;
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0