結果

問題 No.559 swapAB列
ユーザー papinianus
提出日時 2017-08-25 22:58:04
言語 PHP
(843.2)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 36,460 KB
最終ジャッジ日時 2024-10-15 16:07:21
合計ジャッジ時間 4,631 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 4 WA * 1 OLE * 1 -- * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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