Reference's blog

By Reference, history, 7 years ago, In English

If I have N <= 20 elements, I need to arrange them in some way to satisfy a condition(s), what is the number of arrangements mod 1e9 + 7, where an arrangement is different from another arrangement if at least on element is in different locations in the two arrangements, is there some dp trick to know if an arrangement counted before?? note: in this type of problems arrangement may be counted twice because may it's satisfy conditions in two different ways.

Full text and comments »

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

By Reference, history, 8 years ago, In English

in bellman ford algorithm when i relax an edge(u,v) but the distance in u and v is infinite dist[u] = dist[v] = oo and the weight of edge is big negative so what will happen is: dist[u]+w < dist[v] so dist[v] will modified i want to asked if there is necessity to write a condition before the relaxing to avoid that or not and why if not ? because i try some graphs with an arbitary order to edges it gives wrong answer without the condition. thank you all.

Full text and comments »

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