Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let (n,p) = Scanf.scanf " %d %d" (fun a b -> (a, b));;
- let m = Array.make_matrix n (n*n) 0;;
- let flag = ref 0
- let rec checkway m b c =
- if m.(b-1).(c-1) = 1 then flag := 1
- else
- for i = 0 to (n-1) do
- if m.(b-1).(i) = 1 then checkway m (b+1) c
- done;
- if flag = ref 0 then print_endline("NO")
- else print_endline("YES");
- for i = 0 to (p-1) do
- let (a,b,c) = Scanf.scanf " %s %d %d" (fun a b c -> (a, b, c)) in
- if a = "ADD" then m.(b-1).(c-1)<-1
- else if a = "DEL" then m.(b-1).(c-1)<-0
- else checkway m b c;
- Printf.printf "a=%s b=%d c=%d \n" a b c;
- done;
- let mm = Array.make_matrix n (n*n);;
- for i = 0 to (p-1) do
- for i = 0 to (n-1) do
- for j = 0 to (n-1) do
- print_int m.(i).(j)
- done;
- print_newline();
- done;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement