結果

問題 No.548 国士無双
ユーザー mkanmkan
提出日時 2017-09-05 13:05:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,432 bytes
コンパイル時間 1,078 ms
コンパイル使用メモリ 83,596 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 16:19:54
合計ジャッジ時間 1,907 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

string tmp="abcdefghijklm";;

bool ok(string s,char add){
  int greater_than_two=0;
  map<char,int>m;
  s+=add;
  //cout<<s<<endl;
  rep(i,s.size())m[s[i]]++;
  rep(i,tmp.size()){
    //cout<<s[i]<<" "<<m[s[i]]<<endl;
    if(m[tmp[i]]>=2){
      greater_than_two++;
    }else if(m[tmp[i]]==0){
      return false;
    }
  }
  if(greater_than_two==1)return true;
  else return false;
}

int main(){
  string s;
  map<char,int>m;
  vector<char>ans;
  cin>>s;
  rep(i,tmp.size()){
    if(ok(s,tmp[i]))ans.pb(tmp[i]);
  }
  if(ans.size())rep(i,ans.size())cout<<ans[i]<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}
0