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

Автор Mhammad1, история, 8 лет назад, По-английски

I have that problem in my mind and cannot figure out how to solve it, the problem as follow:

Given n clients (1 - n) , m shops and every shop can serve a set of clients (this set is given in the input), so maybe the client can be served by more than one shop, what is the minimum number of shops that can cover(serve) all clients?

I thought about max flow but I failed to come up with the solution.. I know that min cost algorithm will pay for every flow a specific cost, could I modify the algorithm so every X flow will pay only (1) cost?

Any ideas?

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

Given the letters a, b and c , you're only allowed to use these letters.

First combinations that can be made from these letters are: (a) , (b) , (c) , (aa) , (ab) , (ac) , (ba) ....

What is the nth combination that is after the combination x ?

If two combinations have different length, the combination with smallest length comes first, and if they have the same length ** the smallest in alphabetical order comes first**.

Input:

x and n where (|x| <= 1000) and (n <= 10^9)

Examples:

a 2: means given the combination (a) what is the combination that is (2) steps after the combination (a)? Answer is (c)

aa 3: means given the combination (aa) what is the combination that is (3) steps after the combination (aa)? Answer is (ba)

Input:

a 2
b 3
c 1

Output:

c
ab
aa

I had posted this blog before, but I deleted it accidentally, sorry for this.

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

Hello everyone

The problem:

Given 2d array with numbers inside each cell, you should maximize the cost to get from top left (1,1) to bottom right (N,M) with three paths, When you pass to cell(i,j) the cost inside it will be removed for the next paths.

You're only allowed to move down or right.

How can I solve something like this?

I've read the tutorial here TopCoder Tutorial but I didn't understand the whole concept.

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

When I comment on a blog on Codeforces my contribution falls down, but why?

My comments don't have DOWNVOTES, maybe UPVOTES or 0 , but why the contribution is getting down and down?

EDIT: when I posted this my contribution was (-3) and then after about 2 hours it turns to (+8)!! it seems a bug :D :D

Edit2: Ok it was yesterday (+8) and it's now (-1), I think it's a bug !!

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

Hello every one

Is segment tree support insertion, deletion and get kth item? and if it's possible, can you provide me with a resource or code for those functions?

I want something like this:

delete(i) ===> delete the ith item inside the segment tree.

insert(i, val) ====> insert the val in the position i inside the tree.

getKth(k) =====> get the value that is in the kth position inside the tree.

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

Hello every one

I've solved this problem but I have different questions about this problem:

The link : Frequent Values

The questions:

1 — How can I solve this problem if the values not sorted?

2 — How can I solve this problem online?

3 — How can I solve this problem if the values not sorted and online?

Edit: The link for the first question is here: values not sorted

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

I have two different ideas to learn algorithms, but I can't find out which one is best and faster for learning:

1 — Learn a specific algorithm then try to solve the related problems .

2 — Try solving random problems and then try to learn the algorithm that can solve this problem .

And any other ideas to make the learning more efficient?

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

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

Автор Mhammad1, история, 9 лет назад, По-английски

I'm trying to solve this problem:

http://codeforces.net/problemset/problem/455/D

My submission:

http://codeforces.net/contest/455/submission/12009574

My algorithm runs in O(q * sqrt(n)) so it should pass the test cases. So the question is: what's wrong in my code to make it giving me TLE?

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

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