結果

問題 No.587 七対子
ユーザー ohreitetsu
提出日時 2017-11-06 16:23:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 66,912 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 19:45:45
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	int i;
	map<char,int> aMap;
	map<char,int>::iterator mit;
	for (i=0;i<s.length();i++){
		mit=aMap.find(s[i]);
		if (mit==aMap.end()){
			aMap[s[i]]=1;
		}else{
			(*mit).second++;
		}
	}
	char ch;
	char n=0;
	for (mit=aMap.begin();mit!=aMap.end();mit++){
		int num=(*mit).second;
		if (num>2){
			cout<<"Impossible"<<endl;
			return 0;
		}else if (num==1){
			ch=(*mit).first;
			n++;
		}
	}
	if (n==1){
		cout<<ch<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}
0