結果
問題 | No.587 七対子 |
ユーザー |
![]() |
提出日時 | 2018-10-11 09:28:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 958 bytes |
コンパイル時間 | 935 ms |
コンパイル使用メモリ | 103,144 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 19:56:30 |
合計ジャッジ時間 | 1,823 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:55:43: warning: 'ch' may be used uninitialized [-Wmaybe-uninitialized] 55 | (two == 6 && one == 1 ) ? cout << ch << endl : cout << "Impossible" << endl; | ^~ main.cpp:43:14: note: 'ch' was declared here 43 | char ch; | ^~
ソースコード
#include <stdio.h> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <functional> #include <map> #include <iomanip> #include <math.h> #include <stack> #include <queue> #include <bitset> #include <cstdlib> #include <tuple> #include <cctype> #include <ctype.h> #include <set> #include <sstream> using namespace std; int main() { int i, j, k; string s; map<char, int>mp; cin >> s; for (i = 0; i < s.length(); i++) { if (mp.count(s[i]) == 0) { mp.insert(make_pair(s[i], 1)); } else { mp[s[i]]++; } } int one = 0, two = 0; char ch; if (mp.size() != 7) { cout << "Impossible" << endl; return 0; } else if (mp.size() == 7) { for (auto itr = mp.begin(); itr != mp.end(); itr++) { (*itr).second == 2 ? two++ : (*itr).second == 1 ? one++,ch=(*itr).first : 0; } } (two == 6 && one == 1 ) ? cout << ch << endl : cout << "Impossible" << endl; getchar(); getchar(); return 0; }