結果
問題 | No.587 七対子 |
ユーザー |
|
提出日時 | 2024-03-30 17:18:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 3,634 ms |
コンパイル使用メモリ | 256,928 KB |
最終ジャッジ日時 | 2025-02-20 15:56:54 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:28:25: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized] 28 | if (cnt == 7) cout << ans << endl; | ^~~ main.cpp:15:8: note: ‘ans’ was declared here 15 | char ans; | ^~~
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using ll = long long;using ld = long double;string S;map<char, int> mp;int main() {cin >> S;int N = S.size();for (int i = 0; i < N; i++) mp[S[i]]++;char ans;bool flag = false;int cnt = 0;for (auto p: mp) {if (p.second > 2) {cout << "Impossible" << endl;return 0;} else if (p.second == 2) cnt++;else if (p.second == 1) {cnt++;ans = p.first;}}if (cnt == 7) cout << ans << endl;else cout << "Impossible" << endl;return 0;}