Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ=RMQmathrm{RMQ} = mathrm{RMQ}RMQ=RMQ for all 1≤l≤r≤m1 leq l leq r leq m1≤l≤r≤m where RMQmathrm{RMQ}RMQ denotes the index of the minimum element among wl,wl+1,…,wr. Since the array contains distinct elements, the definition of minimum is unambiguous. Bobo has two arrays a and b each with n distinct elements. Find the maximum number p≤np leq np≤n where {a1,a2,…
Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r)=RMQ(v,l,r)mathrm{RMQ}(u, l, r) = mathrm{RMQ}(v, l, r)RMQ(u,l,r)=RMQ(v,l,r) for all 1≤l≤r≤m1 leq l leq r leq m1≤l≤r≤m where RMQ(w,l,r)mathrm{RMQ}(w, l, r)RMQ(w,l,r) denotes the index of the minimum element among wl,wl+1,…,wrw_l, w_{l + 1}, dots, w_{r}wl,wl+1,…,wr. Since the array contains distinct elements, the definition of minimum is unambiguous. Bobo has two arrays a and b each with n distinct elements. Find the maximum number p≤np leq np≤n where {a1,a2,…,ap}{a_1, a_2, dots, a_p}{a1,a2,…,ap} and {b1,b2,…,bp}{b_1, b_2, dots, b_p}{b1,b2,…,bp} are equivalent.