結果
問題 |
No.587 七対子
|
ユーザー |
![]() |
提出日時 | 2017-11-25 11:31:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 88,264 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 19:47:48 |
合計ジャッジ時間 | 1,626 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:43:30: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized] 43 | std::cout << c << std::endl; | ^ main.cpp:25:14: note: 'c' was declared here 25 | char c; | ^
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <map> #include <stack> #include <cmath> #include <queue> #include <numeric> int main() { std::string s; std::cin >> s; std::map<char, int> m; for (size_t i = 0; i < s.length(); i++) { m[s[i]]++; } int count = 0; char c; for (auto i = m.begin(); i != m.end(); i++) { if (i->second > 2) { std::cout << "Impossible" << std::endl; return 0; } if (i->second == 1) { count++; c = i->first; } } if (count == 0 || count > 1) { std::cout << "Impossible" << std::endl; } else { std::cout << c << std::endl; } return 0; }