結果

問題 No.559 swapAB列
ユーザー papinianuspapinianus
提出日時 2017-08-25 22:58:04
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 32,272 KB
実行使用メモリ 39,208 KB
最終ジャッジ日時 2024-04-23 15:41:18
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
39,208 KB
testcase_01 WA -
testcase_02 AC 42 ms
32,144 KB
testcase_03 WA -
testcase_04 AC 41 ms
32,276 KB
testcase_05 AC 42 ms
32,272 KB
testcase_06 AC 40 ms
32,144 KB
testcase_07 AC 43 ms
32,272 KB
testcase_08 OLE -
testcase_09 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$str = trim(fgets(STDIN));
$act = 0;
$lastA = strrpos($str, 'A');
$firstB = strpos($str, 'B');
if($lastA === FALSE || $firstB === FALSE) { echo $act.PHP_EOL; }
while($lastA > $firstB) {
    $len = strlen($str);
    $pos = $firstB;
    while($pos < $lastA) {
        if($str[$pos] == $str[$pos+1]) { $pos++; continue; }
        $temp = $str[$pos];
        $str[$pos] = $str[$pos+1];
        $str[$pos+1] = $temp;
        $act++;
        $pos++;
    }
    $lastA = strrpos($str, 'A');
    $firstB = strpos($str, 'B');
}
echo $act.PHP_EOL;
0