Help in Problem 814C.(2 pointers)

Правка en1, от chinesecoder, 2019-03-10 20:38:49

The problem , 814c , my approach was , for each segment [l, r ] , check whether its possible to color it with at most m colors or not.

since there can be 26*n queries and n^2 segments , the solution will work in 26*n^3 which will give TLE .

The editorial mentions some prefix based approach but i couldn't understand the 2nd part , how its optimizing the solution .

How to reduce 26 * n ^3 to 26*n ^2 . most of submissions used 2 pointers , but how ?

Anyone !

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский chinesecoder 2019-03-10 22:53:51 100
en2 Английский chinesecoder 2019-03-10 20:39:26 10
en1 Английский chinesecoder 2019-03-10 20:38:49 596 Initial revision (published)