Ibrahim-Elsayed's blog

By Ibrahim-Elsayed, history, 15 months ago, In English

You are given three integers $$$n$$$, $$$l$$$, and $$$r$$$, count the number of arrays of size $$$n + 1$$$ that have the first element as the average of the whole array and every element of the array is between $$$l$$$ and $$$r$$$ inclusive. print the number of arrays modulo $$$10^9 + 7$$$.

constraints: $$$1 <= n <= 3000$$$, $$$1 <= l <= r <= 10^{18}$$$

samples: Input: $$$5$$$ $$$1$$$ $$$2$$$, Output: $$$20000$$$ Input: $$$4$$$ $$$2$$$ $$$7$$$, Output: $$$322$$$

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Ibrahim-Elsayed, history, 15 months ago, In English

This problem has DP as a tag in it, I was able to solve it without using DP but since I don't mind getting better at DP (xD) I would like to know how to solve it using DP. I would appreciate your help, thanks in advance.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Ibrahim-Elsayed, history, 15 months ago, In English

Given an array $$$A$$$ of $$$N$$$ non-negative integers, and two different integers $$$x$$$ and $$$y$$$, could you permute the array $$$A$$$ into a new array $$$B$$$ in such a way that after creating the $$$XOR$$$ prefix of the array $$$B$$$, both $$$x$$$ and $$$y$$$ would appear in it?

the $$$XOR$$$ of an empty prefix equals $$$0$$$.

Input: $$$n$$$, $$$x$$$ and $$$y$$$ ($$$2 <= n <= 30$$$), ($$$0 <= x,y < 2^{10}, x \ne y$$$)

then we are given an array $$$A$$$ with length $$$n$$$ $$$a_1, a_2, ..., a_n$$$ ($$$0 <= a_i < 2^{10}$$$)

test cases:

Input: $$$n=5$$$, $$$x=1$$$, $$$y=7$$$, $$$A = [1, 2, 3, 4, 5]$$$

Output: YES

Input: $$$n=3$$$, $$$x=8$$$, $$$y=9$$$, $$$A = [1, 2, 3]$$$

Output: NO

This was a problem in a national contest, we couldn't solve it. I would appreciate your help, thanks in advance.

Full text and comments »

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

By Ibrahim-Elsayed, history, 16 months ago, In English

How to solve this problem using DP?

Full text and comments »

Tags help, dp
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Ibrahim-Elsayed, history, 3 years ago, In English

I'm so happy that today i finally reached pupil after 827 problems on codeforces & 2 years of competitive programming, it feels refreshing and gives you the motivation to continue.

Full text and comments »

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

By Ibrahim-Elsayed, history, 3 years ago, In English

I'm curious about something, is solving harder problems makes you able to solve the easier ones ?, let's say that i find problems with rating $$${X}$$$ are currently challenging for me, so if i just jump to problems with rating $$${Y > X}$$$ and get comfortable solving these (will be much more difficult but it's already difficult anyways) does it make me able to solve problems with rating $$${R < Y}$$$ ?

Full text and comments »

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

By Ibrahim-Elsayed, history, 3 years ago, In English

i recently solved this problem: https://mirror.codeforces.com/contest/1097/problem/B,

I know that it's an easy problem with a brute-force solution but, I'm curious how to solve it for $$${1 <= N <= 10^5}$$$, I'd appreciate your help, thanks in advance.

Full text and comments »

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

By Ibrahim-Elsayed, history, 3 years ago, In English

Work Smarter, Not Harder, can you give me insights on how does the "Smart" part apply in training to get better at CP, and/or does it even apply ? or it just falls to years of hard work ?, (can we accelerate the process ?)

Full text and comments »

  • Vote: I like it
  • -20
  • Vote: I do not like it