結果
問題 | No.587 七対子 |
ユーザー |
![]() |
提出日時 | 2017-11-05 15:28:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 537 bytes |
コンパイル時間 | 418 ms |
コンパイル使用メモリ | 56,684 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 19:45:08 |
合計ジャッジ時間 | 1,582 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:23:26: warning: ‘ans’ may be used uninitialized in this function [-Wmaybe-uninitialized] 23 | cout << char(ans + 'a') << endl; | ~~~~^~~~~
ソースコード
#include <iostream> #include <string> using namespace std; int main(void){ int c[27]; string s; cin >> s; fill(c, c+27, 0); for(int i=0; i<s.length(); i++){ c[s[i]-'a']++; } int cnt2=0,cnt1=0, ans; for(int i=0; i<27; i++){ if(c[i] == 2){ cnt2++; }else if(c[i] == 1){ cnt1++; ans = i; } } if(cnt2 == 6 && cnt1 == 1){ cout << char(ans + 'a') << endl; }else{ cout << "Impossible" << endl; } return 0; }