Comparing Permutations of Subarrays Problem

Правка en3, от vamaddur, 2017-07-06 12:14:20

We are given an array of size N and Q queries (1 <= N, Q <= 100000). Each query has 4 parameters: index i, index j, length L, and differences D (0 <= D <= 1). We must answer "YES" if a permutation of the subarray from arr[i] to arr[i+L-1] differs from a permutation of the subarray from arr[j] to arr[j+L-1] in at most D places, and "NO" otherwise.

This sounds like an offline segment tree problem, but I am not sure how to start implementing it.

Can someone give me some hints to get me started and moving in the right direction?

Please help, and thanks in advance!

UPD: Just for the sake of it, I tried submitting a naive N^2 solution, which didn't make it in the time limit of 2 seconds, as expected.

UPD2: Original problem statement is here.

Теги offline query, segment tree, permutation, subarray

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский vamaddur 2017-07-06 12:14:20 81
en2 Английский vamaddur 2017-07-06 08:17:07 139
en1 Английский vamaddur 2017-07-05 10:55:21 618 Initial revision (published)