結果
| 問題 | No.455 冬の大三角 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-09-09 15:44:57 |
| 言語 | OCaml (5.2.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 809 bytes |
| 記録 | |
| コンパイル時間 | 72 ms |
| コンパイル使用メモリ | 16,896 KB |
| 最終ジャッジ日時 | 2024-11-14 20:14:57 |
| 合計ジャッジ時間 | 914 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 14, characters 30-42:
14 | if i = x then (s.[y] <- '*'; printf "%s\n" s)
^^^^^^^^^^^^
Error: Syntax error: strings are immutable, there is no assignment syntax for them.
Hint: Mutable sequences of bytes are available in the Bytes module.
Hint: Did you mean to use 'Bytes.set'?
ソースコード
open Printf
open Scanf
let find ar h w =
let rec iter i j ps =
if i = h then ps
else if j = w then iter (i+1) 0 ps
else if ar.(i).[j] = '*' then iter i (j+1) ((i,j) :: ps)
else iter i (j+1) ps in
iter 0 0 []
let print_tbl ar w x y =
Array.iteri (fun i s ->
if i = x then (s.[y] <- '*'; printf "%s\n" s)
else printf "%s\n" s) ar
let () =
let h, w = scanf "%d %d " (fun x y -> (x, y)) in
let tbl = Array.init h (fun _ -> let s = scanf "%s " (fun x -> x) in s) in
match find tbl h w with
(x1, y1) :: (x2, y2) :: _ -> begin
let rec loop i j =
if j = w then loop (i+1) 0
else if (x1-i) * (y2-j) - (y1-j) * (x2-i) = 0 then loop i (j+1)
else print_tbl tbl w i j in
loop 0 0
end
| _ -> failwith "find"