結果
| 問題 |
No.587 七対子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-10 12:33:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 676 bytes |
| コンパイル時間 | 860 ms |
| コンパイル使用メモリ | 76,856 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 19:46:27 |
| 合計ジャッジ時間 | 1,447 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:17: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
30 | cout << res << endl;
| ^~~
main.cpp:21:14: note: 'res' was declared here
21 | char res;
| ^~~
ソースコード
#include <iostream>
#include <map>
#include <string>
int main() {
using namespace std;
string s;
cin >> s;
map<char, int> cc;
for (const char c: s) {
if (cc.find(c) == cc.end()) {
cc[c] = 1;
} else {
cc[c]++;
}
}
if (cc.size() != 7) {
cout << "Impossible" <<endl;
return 0;
} else {
char res;
for (const pair<char, int> n: cc) {
if (n.second == 1) {
res = n.first;
} else if (n.second > 2) {
cout << "Impossible" <<endl;
return 0;
}
}
cout << res << endl;
}
}