811E solution(Segment tree)

Revision en5, by g1n0st, 2017-06-03 14:47:06

811E - Vladik and Entertaining Flags

This is 811E's solution by g1n0st

In the contest I didn't pass this problem because I'm very rubbish.

After reading the question, I thought it is very difficult at first. And then I found:

  • N only in range of 10

  • Every matrices of requests are from [1, l] to [r, n]

So it means, if we use Segment tree to maintain the main matrix (1, 1, n, m) , we needn't usd two dimension Segment tree but common. For every nodes (l, r) on the tree we define two arrayes L [1, n] and R [1..n] describing the situations of the sequence's beginning and ending, and a integer number to record sequence's value, then we can use union-find sets to maintain two sequences.

It works in O(MlogM * N)

Tags 811e, segment tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English g1n0st 2017-06-03 14:47:06 1 Tiny change: ',n]$ and R$[1..n]$ d' -> ',n]$ and R $[1..n]$ d'
en4 English g1n0st 2017-06-03 14:46:49 2 Tiny change: 'ain matrix$(1,1,n,m)$, we needn' -> 'ain matrix $(1,1,n,m)$ , we needn'
en3 English g1n0st 2017-06-03 14:46:23 2 Tiny change: 'ain matrix$(1,1,n,m)$, we needn' -> 'ain matrix $(1,1,n,m)$ , we needn'
en2 English g1n0st 2017-06-03 14:45:45 51
en1 English g1n0st 2017-06-01 16:30:28 702 Initial revision (published)