Welcome

Coders,Lets Code

×
Nature

Problem 1

Aditya gupta, March 16, 2019

Find the output of the given probelm ?

Same

Comments   0


Norway

Problem 2

Rohit Singh Bisht, Feb 14, 2019

While Kim notes down the different base plans possible, Soum pulls a lever from the control room, and Kim falls into a trapped cell! Has the JSA won the battle? Unfortunately for the JSA, Kim is a genius, so he has obviously easily escaped from his cell. However, he found that his cell is only one in a large underground network of cells. Now he needs to find a way to escape! Of course, since it is a prison, some of the cells are locked at all times. However, some prison guards are lazy and left the keys for a cell in another cell. Each key can only unlock one cell and each cell can only be unlocked by one key. If any cell does not have a corresponding key, it is unlocked. The prison consists of N cells labelled 1 to N with cell 1 being Kim's starting position and cell N being the exit of the underground prison network. Furthermore, there are E bidirectional connections between cells. The i-th connection takes Kim Ci seconds to pass through, and connects cells Ai and Bi. Kim takes no time to pick up a key when he reaches a cell containing a key, and takes no time to unlock a door with a key. Cells 1 and N never have any keys in them. Additionally, no two keys will ever be found in the same cell. Can you help Kim find the minimum time it would take him to go from cell 1 to cell N?

... Input: The first line of input contains 3 integers N, E and K denoting the number of cells, number of connections and the number of keys. The following E lines contain 3 integers, Ai, Bi and Ci showing that a connection exists between cell Ai and Bi taking Ci time to traverse. The following K lines contain 2 integers, L and U denoting that the key for cell U is located at cell L. Output: Print one number S which is the time from cell 1 to cell N. If this is not possible print -1. The answer is guaranteed to fit into a 64 bit integer.

Comments   2


Top Used Language

  • Image C Programming
    Begineer
  • Image C++
    Elementary
  • Image Java
    Intermediate
  • Image Python
    Upper Intermediate