Frame-workout 2#980

Frame-workout 2

1 sekunda
64 megabajty
Bardzo łatwe

Find a pair of vertices in a complete undirected weighted graph according to specified criteria.

Dane wejściowe

The input file contains a number (2 \leq N \leq 100) and the adjacency matrix of a complete undirected weighted graph (a complete graph is a graph in which there are edges between all pairs of vertices). All edge weights are natural numbers from to . Then, numbers are given, each either or —these numbers are assigned to the vertices. It is guaranteed that there is at least one and at least one .

Dane wyjściowe

Find and print two vertices such that:

  • the first vertex is assigned

  • the second vertex is assigned

  • the edge connecting these two vertices has the minimal possible weight

If there are multiple such pairs, output any of them.

Przykłady

Przykład 1

Loading
Loading