結果
問題 | No.401 数字の渦巻き |
ユーザー | sam_kino |
提出日時 | 2016-08-06 10:25:42 |
言語 | PHP (8.3.4) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 2,188 bytes |
コンパイル時間 | 3,180 ms |
コンパイル使用メモリ | 30,336 KB |
実行使用メモリ | 31,260 KB |
最終ジャッジ日時 | 2024-04-24 18:09:45 |
合計ジャッジ時間 | 5,740 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
30,904 KB |
testcase_01 | AC | 41 ms
31,228 KB |
testcase_02 | AC | 43 ms
31,036 KB |
testcase_03 | AC | 41 ms
31,032 KB |
testcase_04 | AC | 41 ms
31,076 KB |
testcase_05 | AC | 40 ms
31,204 KB |
testcase_06 | AC | 42 ms
31,164 KB |
testcase_07 | AC | 40 ms
31,140 KB |
testcase_08 | AC | 42 ms
31,028 KB |
testcase_09 | AC | 40 ms
31,012 KB |
testcase_10 | AC | 40 ms
31,228 KB |
testcase_11 | AC | 41 ms
30,984 KB |
testcase_12 | AC | 41 ms
31,032 KB |
testcase_13 | AC | 42 ms
31,020 KB |
testcase_14 | AC | 40 ms
30,988 KB |
testcase_15 | AC | 41 ms
30,912 KB |
testcase_16 | AC | 41 ms
31,056 KB |
testcase_17 | AC | 41 ms
30,952 KB |
testcase_18 | AC | 42 ms
31,020 KB |
testcase_19 | AC | 41 ms
31,008 KB |
testcase_20 | AC | 42 ms
31,260 KB |
testcase_21 | AC | 41 ms
31,016 KB |
testcase_22 | AC | 41 ms
30,768 KB |
testcase_23 | AC | 41 ms
30,972 KB |
testcase_24 | AC | 41 ms
31,028 KB |
testcase_25 | AC | 42 ms
31,008 KB |
testcase_26 | AC | 42 ms
30,900 KB |
testcase_27 | AC | 42 ms
31,088 KB |
testcase_28 | AC | 42 ms
31,052 KB |
testcase_29 | AC | 42 ms
30,956 KB |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $n=trim(fgets(STDIN)); //初期設定 for($i=0;$i<$n;$i++){ for($k=0;$k<$n;$k++){ $anss[$i][$k]=0;//配列に同じ値セット } } $num=1; $st=0; //Start $yoko_ofset=0; //Tate change $tate_ofset=0; $yoko=0; $tate=0; $width=$n-1; //$n-1; // n-1 幅・横 while(1){ for($i=0;$i<$width;$i++){ //上・横 --->A //$yoko_ofset=0; $anss[$yoko+$yoko_ofset][$tate+$tate_ofset]=$num; //echo "A:".$anss[$yoko+$yoko_ofset][$tate+$tate_ofset].PHP_EOL; $num++; $yoko++; if($num>=$n*$n+1) break 2; } //----------------------------------------------------- for($i=0;$i<$width;$i++){ //down B //$yoko_ofset=0; $anss[$yoko+$yoko_ofset][$tate+$tate_ofset]=$num; //echo "B:".$anss[$yoko+$yoko_ofset][$tate+$tate_ofset].PHP_EOL; $num++; $tate++; if($num>=$n*$n+1) break 2; } //------------------------------------------------------ for($i=0;$i<$width;$i++){ //下・横 <--- C //$yoko_ofset=0; $anss[$yoko+$yoko_ofset][$tate+$tate_ofset]=$num; //echo "C:".$anss[$yoko+$yoko_ofset][$tate+$tate_ofset].PHP_EOL; $num++; $yoko--; if($num>=$n*$n+1) break 2; } //------------------------------------------------------- for($i=0;$i<$width;$i++){ //down D //$yoko_ofset=0; $anss[$yoko+$yoko_ofset][$tate+$tate_ofset]=$num; //echo "D:".$anss[$yoko+$yoko_ofset][$tate+$tate_ofset].PHP_EOL; $num++; $tate--; if($num>=$n*$n+1) break 2; } if($width==0){ $anss[$yoko+$yoko_ofset][$tate+$tate_ofset]=$num; //echo "END:".$anss[$yoko+$yoko_ofset][$tate+$tate_ofset].PHP_EOL; $num++; } $st=$st+1; $yoko_ofset=$yoko_ofset+1; // 横移動 $tate_ofset=$tate_ofset+1; $width=$width-2; if($num>=$n*$n+1) break; } // 表示 for($i=0;$i<$n;$i++){ for($k=0;$k<$n;$k++){ printf("%03d ", $anss[$k][$i]); if($k==$n-1){ echo PHP_EOL; } } }