Submission #6706983


Source Code Expand

Copy
<?php
$s = str_split(trim(fgets(STDIN)));

$res = [];
for ($i = 0; $i < count($s); $i++) {
    $res[$i] = 0;
}

for ($i = 0; $i < count($s); $i++) {
    $x = $i; // 現在位置記録
    for ($j = 0; true; $j++) {
        if ($s[$x] === 'L') {
            if ($s[$x - 1] === 'R') { // 循環($j回移動済み)
                if ($j % 2 === 0) { //残り偶数回移動
                    $res[$x]++;
                } else { // 残り奇数回移動
                    $res[$x - 1]++;
                }
                break;
            }
            $x--;
        } elseif($s[$x] === 'R') {
            if ($s[$x + 1] === 'L') { // 循環
                if ($j % 2 === 0) { //残り偶数回移動
                    $res[$x]++;
                } else { // 残り奇数回移動
                    $res[$x + 1]++;
                }
                break;
            }
            $x++;
        }
    }
}
echo implode(' ', $res).PHP_EOL;

Submission Info

Submission Time
Task D - Gathering Children
User hideyuk1
Language PHP7 (7.0.15)
Score 0
Code Size 985 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
All 0 / 400 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 12 ms 4728 KB
sample_02 9 ms 4604 KB
sample_03 9 ms 4604 KB
testcase_01 32 ms 10872 KB
testcase_02 30 ms 10872 KB
testcase_03 50 ms 15992 KB
testcase_04 45 ms 15992 KB
testcase_05
testcase_06
testcase_07
testcase_08 1138 ms 15992 KB
testcase_09
testcase_10
testcase_11 35 ms 15992 KB
testcase_12 863 ms 15864 KB
testcase_13 977 ms 15992 KB
testcase_14
testcase_15
testcase_16
testcase_17
testcase_18 9 ms 4604 KB