結果
問題 | No.401 数字の渦巻き |
ユーザー |
|
提出日時 | 2023-10-30 16:52:43 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,286 bytes |
コンパイル時間 | 664 ms |
コンパイル使用メモリ | 33,892 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 17:19:20 |
合計ジャッジ時間 | 1,656 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
program yukicoder_401use, intrinsic :: iso_fortran_envimplicit noneinteger(int32) :: n, y, x, next_y, next_x, directioninteger(int32), allocatable :: grids(:, :)integer(int32) :: iread(input_unit, *) nallocate(grids(0:n+1, 0:n+1), source = -1)grids(0, :) = huge(0_int32)grids(:, 0) = huge(0_int32)grids(n + 1, :) = huge(0_int32)grids(:, n + 1) = huge(0_int32)y = 1; x = 1direction = 1do i = 1, n * ngrids(y, x) = i! write(error_unit, *) grids(1:n, 1:n)select case(direction)case(1) !> EAST.if (grids(y, x + 1) > 0) thendirection = 2y = y + 1elsex = x + 1end ifcase(2) !> SOUTH.if (grids(y + 1, x) > 0) thendirection = 3x = x - 1elsey = y + 1end ifcase(3) !> WEST.if (grids(y, x - 1) > 0) thendirection = 4y = y - 1elsex = x - 1end ifcase(4) !> NORTH.if (grids(y - 1, x) > 0) thendirection = 1x = x + 1elsey = y - 1end ifend selectend dodo i = 1, nwrite(output_unit, '(*(i3.3, 1x))') grids(i, 1:n)end doend program yukicoder_401