結果

問題 No.587 七対子
ユーザー yukiteruyukiteru
提出日時 2018-02-05 16:11:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 19:50:35
合計ジャッジ時間 1,536 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	string s;
	int dp[27] = {};
	int p = -1;
	bool flag = true;
	

	cin >> s;
	FOR(i, 0, 12) {
		FOR(t, 1, 26) {
			if (s[i] == 'a' + t - 1) {
				dp[t]++;
				break;
			}
		}
	}
	FOR(i, 1, 26) {
		if (dp[i] >= 3) {
			flag = false;
			break;
		}else if (dp[i] ==2) {
			continue;
		}
		else if(dp[i]==1) {
			if (p==-1) {
				p = i;
			}
			else {
				flag = false;
				break;
			}
		}
	}
	if (flag) {
		printf("%c\n", p + 'a' - 1);
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}
0