結果
問題 |
No.559 swapAB列
|
ユーザー |
![]() |
提出日時 | 2017-10-15 14:32:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 503 bytes |
コンパイル時間 | 527 ms |
コンパイル使用メモリ | 54,900 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 17:43:16 |
合計ジャッジ時間 | 1,006 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:28: warning: ‘bpos’ may be used uninitialized in this function [-Wmaybe-uninitialized] 29 | cout << apos - bpos << "\n"; | ^~~~ main.cpp:29:28: warning: ‘apos’ may be used uninitialized in this function [-Wmaybe-uninitialized]
ソースコード
#include <iostream> #include <string> using namespace std; int main() { string ab; cin >> ab; int len = ab.length(); int bpos; for (int i = 0; i < len; i++) { if (ab[i] == 'B') { bpos = i; break; } } int apos; for (int i = len - 1; i >= 0; i--) { if (ab[i] == 'A') { apos = i; break; } } cout << apos - bpos << "\n"; int a; cin >> a; }