e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Frame-workout 2

Frame-workout 2

Find apair ofverticesina complete undirectedweightedgraphaccording tospecifiedcriteria.

Input

In the inputfileis givena numberN (from 2to100)andthe adjacency matrix ofa completeundirectedweightedgraph(complete graph-a graph inwhichthere areedgesbetween allpairs ofvertices).All theweights of the edges-natural numbersfrom1to1000.Further,givenNnumbers,eachof which iseither0or1- it is believedthat thesenumbers are written inthe tops.It is guaranteedthatat least one0andatleastone1.

Output

Locateand bringin the outputfilearethe two verticesthat:

  • the first oftheseis0
  • the secondofwhichis worth 1
  • weight ofthe edgebetween thevertices ofthe minimumpossible.

Ifseveralsuchpairs, displayany ofthem.

Time limit 1 second
Memory limit 64 MiB
Input example #1
3
0 1 2 
1 0 4 
2 4 0
1 0 0
Output example #1
2 1