With your modified code it would rather be
flag = all(A[i] == B[C[i], i] for i in 1:n)
but you know better what you really want.
With your modified code it would rather be
flag = all(A[i] == B[C[i], i] for i in 1:n)
but you know better what you really want.