結果
問題 | No.1362 [Zelkova 8th Tune] Black Sheep |
ユーザー |
![]() |
提出日時 | 2023-04-02 22:57:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 1,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 64,652 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 00:39:48 |
合計ジャッジ時間 | 2,511 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:20:43: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 20 | if (a_count == 1) cout << 1 << " " << a << endl; | ^ main.cpp:8:10: note: 'a' was declared here 8 | char a, b; | ^ main.cpp:21:35: warning: 'bp' may be used uninitialized [-Wmaybe-uninitialized] 21 | else cout << bp + 1 << " " << b << endl; | ^ main.cpp:10:9: note: 'bp' was declared here 10 | int bp; | ^~ main.cpp:21:35: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized] 21 | else cout << bp + 1 << " " << b << endl; | ^ main.cpp:8:13: note: 'b' was declared here 8 | char a, b; | ^
ソースコード
#include<iostream>#include<string>using namespace std;int main() {string s;cin >> s;char a, b;int a_count = 1, b_count = 0;int bp;for (int i = 0; i < (int)s.size(); i++) {if (i == 0) a = s[i];else if (s[i] != a) {b = s[i];b_count++;bp = i;}else a_count++;}if (a_count == 1) cout << 1 << " " << a << endl;else cout << bp + 1 << " " << b << endl;return 0;}