結果
| 問題 | No.587 七対子 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-01-01 01:31:58 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 448 bytes | 
| コンパイル時間 | 1,438 ms | 
| コンパイル使用メモリ | 173,004 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 19:57:09 | 
| 合計ジャッジ時間 | 2,500 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 35 | 
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:24:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   24 |                 cout << ans << endl;
      |                         ^~~
main.cpp:15:14: note: 'ans' was declared here
   15 |         char ans;
      |              ^~~
            
            ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	string s;
	cin >> s;
	map<char, int> mp;
	for(int i = 0; i < s.size(); i++) {
		mp[s[i]]++;
	}
	int one = 0, two = 0;
	char ans;
	for(auto i : mp) {
		if(i.second == 2) two++;
		if(i.second == 1) {
			one++;
			ans = i.first;
		}
	}
	if(one == 1 && two == 6) {
		cout << ans << endl;
	} else {
		cout << "Impossible" << endl;
	}
	return 0;
}
            
            
            
        