Блог пользователя elizabeth_zou_fanboi

Автор elizabeth_zou_fanboi, история, 5 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

Автор elizabeth_zou_fanboi, история, 17 месяцев назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • +17
  • Проголосовать: не нравится