結果
問題 | No.587 七対子 |
ユーザー |
![]() |
提出日時 | 2020-10-04 22:14:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 172,808 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 20:22:07 |
合計ジャッジ時間 | 2,517 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:41:30: warning: 'c' may be used uninitialized [-Wmaybe-uninitialized] 41 | cout << c << "\n"; | ^~~~ main.cpp:23:14: note: 'c' was declared here 23 | char c; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; map<char, int> m; for (const auto& it : s) ++m[it]; bool ok = true; int odd{ 0 }; char c; for (const auto& it : m) { if (it.second > 2) { ok = false; break; } else if (it.second == 1) { c = it.first; ++odd; } } if (!ok || odd > 1) cout << "Impossible\n"; else cout << c << "\n"; return 0; }