結果
問題 |
No.587 七対子
|
ユーザー |
![]() |
提出日時 | 2018-08-08 09:36:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 77,420 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 19:54:52 |
合計ジャッジ時間 | 1,658 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:14: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized] 25 | char c; | ^
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<functional> #include<vector> #include<set> #include<queue> #include<list> #include<stdio.h> #include<stdlib.h> #include<map> using namespace std; int main() { string s; cin >> s; map<char, int> m; for (char c : s) ++m[c]; int cnt = 0; char c; //型推計とforeach覚えろ。 for (auto p : m) { if (p.second == 2) cnt++; else c = p.first; } //13個のうち2*6が決まっていれば残りは1個しかない。 //2個ペアが6個あるか調べるだけでいい。 if (cnt == 6) cout << c << endl; else cout << "Impossible" << endl; return 0; }