結果
問題 | No.587 七対子 |
ユーザー |
![]() |
提出日時 | 2021-02-05 21:14:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 380 bytes |
コンパイル時間 | 1,622 ms |
コンパイル使用メモリ | 169,788 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 11:28:03 |
合計ジャッジ時間 | 2,862 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:19:24: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized] 19 | cout << (char)(ans + 'a') << endl; | ~~~~~^~~~~~ main.cpp:8:17: note: 'ans' was declared here 8 | int pair = 0, ans; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; vector<int> A(26); int pair = 0, ans; for (char c : S) A.at(c - 'a')++; for (int i = 0; i < 26; i++) { if (A.at(i) == 2) pair++; else if (A.at(i) == 1) ans = i; } if (pair == 6) cout << (char)(ans + 'a') << endl; else cout << "Impossible" << endl; }