elizabeth_zou_fanboi's blog

By elizabeth_zou_fanboi, history, 5 months ago, In English

If the operation in this question (round 1063 B) is changed as follows: Choose any two integers l and r such that 1≤l≤r≤n. If, for ALL i in range (l,r) , min(pl,pr)<pi<max(pl,pr) holds true then set si to 1 for ALL i in range (l,r)

Is there solution to this variation. I spent whole contest on this variation (misread the question). I want to know whether solution exists in O(n) or not.

My O(n*5) solution that I am not sure is correct:

my code

Full text and comments »

By elizabeth_zou_fanboi, history, 17 months ago, In English

a permutation is valid only if |ai — i| != k for all 1<=i<=n. Count the number of valid permutations.

Constraints: 2 ≤ N ≤ 2000

1 ≤ K ≤ N − 1

EDIT: Thanks for the explanation from TAhmed33.

I implemented that explanation:

cpp code

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it