結果

問題 No.455 冬の大三角
ユーザー papinianuspapinianus
提出日時 2016-12-06 12:51:21
言語 PHP
(8.3.4)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,526 bytes
コンパイル時間 1,068 ms
コンパイル使用メモリ 18,400 KB
実行使用メモリ 19,020 KB
最終ジャッジ日時 2023-09-12 08:30:13
合計ジャッジ時間 5,544 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,932 KB
testcase_01 AC 15 ms
18,912 KB
testcase_02 AC 15 ms
18,868 KB
testcase_03 AC 15 ms
18,836 KB
testcase_04 AC 16 ms
18,832 KB
testcase_05 AC 16 ms
18,740 KB
testcase_06 AC 15 ms
18,920 KB
testcase_07 AC 15 ms
18,936 KB
testcase_08 AC 15 ms
18,940 KB
testcase_09 AC 15 ms
18,940 KB
testcase_10 AC 15 ms
18,728 KB
testcase_11 AC 15 ms
18,856 KB
testcase_12 AC 15 ms
18,864 KB
testcase_13 AC 15 ms
18,820 KB
testcase_14 AC 16 ms
18,896 KB
testcase_15 AC 15 ms
18,960 KB
testcase_16 AC 15 ms
18,916 KB
testcase_17 AC 15 ms
18,896 KB
testcase_18 AC 15 ms
18,832 KB
testcase_19 AC 15 ms
18,732 KB
testcase_20 AC 15 ms
18,892 KB
testcase_21 AC 15 ms
18,896 KB
testcase_22 AC 16 ms
18,764 KB
testcase_23 AC 16 ms
18,916 KB
testcase_24 AC 16 ms
18,956 KB
testcase_25 AC 15 ms
18,844 KB
testcase_26 AC 16 ms
18,928 KB
testcase_27 AC 16 ms
18,788 KB
testcase_28 AC 15 ms
18,784 KB
testcase_29 AC 15 ms
18,824 KB
testcase_30 AC 16 ms
18,868 KB
testcase_31 AC 16 ms
18,732 KB
testcase_32 AC 15 ms
18,804 KB
testcase_33 AC 16 ms
18,936 KB
testcase_34 AC 15 ms
18,812 KB
testcase_35 AC 16 ms
18,732 KB
testcase_36 AC 16 ms
18,860 KB
testcase_37 AC 15 ms
19,020 KB
testcase_38 AC 15 ms
18,700 KB
testcase_39 AC 16 ms
18,824 KB
testcase_40 AC 16 ms
18,900 KB
testcase_41 AC 15 ms
18,848 KB
testcase_42 AC 15 ms
18,856 KB
testcase_43 AC 16 ms
18,852 KB
testcase_44 AC 15 ms
18,884 KB
testcase_45 AC 15 ms
18,896 KB
testcase_46 AC 15 ms
18,896 KB
testcase_47 AC 15 ms
18,848 KB
testcase_48 AC 16 ms
18,904 KB
testcase_49 AC 15 ms
18,828 KB
testcase_50 AC 15 ms
18,852 KB
testcase_51 AC 15 ms
18,912 KB
testcase_52 AC 15 ms
18,824 KB
testcase_53 AC 15 ms
18,920 KB
testcase_54 AC 15 ms
18,760 KB
testcase_55 AC 15 ms
18,732 KB
testcase_56 AC 15 ms
18,924 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
list($h, $w) = explode(" ", trim(fgets(STDIN)));
for($i = 0, $found = 0; $i < $h; $i++)
{
    $input = trim(fgets(STDIN));
    $sky[] = $input;
    if($found > 1) {continue;}
    $pos = strpos($input, "*");
    if($pos === FALSE) {continue;}
    $stars[$found] = [$i, $pos];
    $found++;
    if($found > 1) {$continue;}
    $rpos = strrpos($input, "*");
    if($rpos === FALSE || $rpos === $pos) {continue;}
    $stars[$found] = [$i, $rpos];
    $found++;
}
$third = getAddedPosition($stars[0], $stars[1]);
$sky[$third[0]][$third[1]] = '*';
array_reverse($sky);
foreach($sky as $row)
{
    echo $row.PHP_EOL;
}

function getAddedPosition($star1, $star2)
{
    $candidates = [[0,0],[1,0],[0,1]];
    foreach($candidates as $candidate)
    {
        if($star1[0] == $candidate[0] && $star1[1] == $candidate[1]) {continue;}
        if($star2[0] == $candidate[0] && $star2[1] == $candidate[1]) {continue;}
        if($star1[0] == $candidate[0] && $star2[0] == $candidate[0]) {continue;}
        if($star1[1] == $candidate[1] && $star2[1] == $candidate[1]) {continue;}
        if($star1[0] == $candidate[0] || $star2[0] == $candidate[0] || $star1[0] == $star2[0]) {return $candidate;}
        if($star1[1] == $candidate[1] || $star2[1] == $candidate[1] || $star1[1] == $star2[1]) {return $candidate;}
        $twoone = ($star2[0] - $star1[0]) / ($star2[1] - $star1[1]);
        $onecan = ($star1[0] - $candidate[0]) / ($star1[1] - $candidate[1]);
        if($twoone == $onecan) {continue;}
        return $candidate;
    }
}
0