Diferență între revizuiri ale paginii „DSA Homework 5”

De la WikiLabs
Jump to navigationJump to search
(Pagină nouă: = Data Centers = Little John is all grown up now and working in a high tech data center. One day, as he got to work, he finds out that hackers attacked his network and managed to dis...)
 
Linia 28: Linia 28:
 
|
 
|
 
<pre style="font-size:12px">
 
<pre style="font-size:12px">
8
+
5
Mircea
+
0 1 1 0 0
a
+
1 0 1 0 0
mancat
+
1 1 0 1 1
cartofi
+
0 0 1 0 1
si
+
0 0 1 1 0
piure
+
1
de
+
2
cartofi
+
0 4
 
</pre>
 
</pre>
 
|
 
|
 
<pre style="font-size:12px">
 
<pre style="font-size:12px">
7
+
0
Mircea
 
a
 
cartofi
 
de
 
mancat
 
piure
 
si
 
 
</pre>
 
</pre>
 
|}
 
|}

Versiunea de la data 26 aprilie 2014 09:03

Data Centers

Little John is all grown up now and working in a high tech data center. One day, as he got to work, he finds out that hackers attacked his network and managed to disable some of the servers. A disabled server can't route data in or out, so they behave as all links to and from those nodes are disabled. Some of the remaining servers are critical to data access within his company and he wants to know if there is still a route for the data between them.

Help Little John write a program to find out if those servers are still linked.

Requirement

Given a number of servers N and an adjacency matrix NxN specifying the links between those servers, a number K of failed servers, and pair of servers (i, j), specify if there is still a route between server i and server j.

Input Data

A file called data_center.in, containing the number of servers N on the first line and N x N subsequent values, defining the adjacency matrix, arranged in a square, on N lines, followed by the number K of failed servers, K values specifying the servers on the following line, and the pair (i, j) on the last line.

Output Data

A file called data_center.out, containing the value 0 if there is no route between the two specified servers and 1 if there is.

Restrictions

1 ≤ K ≤ N ≤ 1000

Examples

Input Output
5
0 1 1 0 0
1 0 1 0 0
1 1 0 1 1
0 0 1 0 1
0 0 1 1 0
1
2
0 4
0