結果
問題 | No.587 七対子 |
ユーザー |
![]() |
提出日時 | 2017-12-23 08:31:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 503 bytes |
コンパイル時間 | 521 ms |
コンパイル使用メモリ | 62,864 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 19:49:26 |
合計ジャッジ時間 | 1,480 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:14: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] 12 | char ans; | ^~~
ソースコード
#include <iostream> #include <string> #include <math.h> #include <algorithm> using namespace std; typedef long long int ll; typedef pair<ll, ll> P; int main() { string s; cin >> s; ll cnt[27] = {}, a, A = 0, B = 0; char ans; for (int i = 0; i < 13; i++) { a = s[i] - 'a' + 1; cnt[a]++; } for (int i = 1; i <= 26; i++) { if (cnt[i] == 2)A++; if (cnt[i] == 1) { B++; ans = 'a' + i - 1; } } if (A == 6 && B == 1)cout << ans << endl; else cout << "Impossible" << endl; return 0; }