• 沒有找到結果。

# • Problem Input: Input to each problem are done through the input file. Input filenames are given in the Problem Information Sheet.

N/A
N/A
Protected

Share "• Problem Input: Input to each problem are done through the input file. Input filenames are given in the Problem Information Sheet."

Copied!
33
0
0

(1)

### certain time limit (given in the Problem Information Sheet).

(2)

Table 1: Problem Information Sheet

Problem Name Input File Time Limit

Problem A Poker Card Game pa.dat 30 secs.

Problem B The Longest Detour Problem pb.dat 30 secs.

Problem C The Strongest Subchains pc.dat 30 secs.

Problem D Tag Trees pd.dat 30 secs.

Problem E Rooted Trees Isomorphism pe.dat 30 secs.

Problem F Tree Size Problem pf.dat 30 secs.

Problem G Packet Radio Routing Problem pg.dat 30 secs.

Problem H Secret Sharing Problem ph.dat 30 secs.

(3)

### Poker Card Game Input File: pa.dat

Suppose you are given many poker cards. As you have already known, each card has points ranging from 1 to 13. Using these poker cards, you need to play a game on the cardboard in Figure 1. The game begins with a place called START. From START, you can walk to left or right to a rectangular box. Each box is labeled with an integer, which is the distance to START.

START

1 1

2 2 2 2

Figure 1: The poker card game cardboard.

To place poker cards on these boxes, you must follow the rules below:

(1) If you put a card with n points on a box labeled i , you got (n ∗ i) points.

(2) Once you place a card on a box b, you block the paths to the boxes behind b.

For example, in Figure 2, a player places a queen on the right box of distance 1, he gets 1 ∗ 12 points but the queen also blocks the paths to boxes behind it; i.e., it is not allowed to put cards on boxes behind it anymore.

START 1

2 2

Q

Figure 2: Placing a queen.

(4)

Your goal: Given a number of poker cards, find a way to place them so that you will get the minimum points. For example, suppose you have 3 cards 5, 10, and K. To get the minimum points, you can place cards like Figure 3, where the total points are 1 ∗ 13 + 2 ∗ 5 + 2 ∗ 10 = 43.

START 1

5 2

K 10

Figure 3: An example to place cards.

### Input

: The first line of the input file contains an integer n, n ≤ 10, which represents the number of test cases. In each test case, it begins with an integer m, m ≤ 100000, which represents the number of poker cards. Next, each card represented by its number are listed consecutively. Note that, the numbers of ace, 2, 3, · · ·, K are given by integers 1, 2, 3, · · ·, 13, respectively. The final minimum point in each test case is less than 5000000.

### Output

: List the minimum points of each test case line by line.

(5)

3 3

5 10 13 4

3 4 5 5 5

7 7 10 11 13

43 34 110

(6)

### Input File: pb.dat

Let G be a weighted graph, i.e., every edge in G is associated with a nonnegative integer weight. The length of a path is the sum of edge weights in the path. A shortest path between vertices r and s in G, denoted by PG(r, s), is defined as a path with the shortest length from r to s. The distance between vertices r and s, denoted by dG(r, s), is the length of the shortest path PG(r, s). For two vertices in a connected graph, there exists at least one shortest path between them. Let e = (u, v) be an edge in PG(r, s) with v closer to s than u (v may be s). Let G − e denote the subgraph obtained by removing edge e from G. A detour from u is the shortest path from u to s in G − e, or PG−e(u, s). Edge e is a detour-critical edge in PG(r, s) if the removal of e results in the maximum distance increment from u to s. In other words, if e is a detour-critical edge in PG(r, s), then dG−e(u, s) − dG(u, s) is maximum among all edges in PG(r, s). The longest detour problem is to find the maximum distance increment of a shortest path.

1

6 2

3

4 5

500 500 100

100 200

400

300 100

100

100

Figure 4: A weighted graph G.

For example, see Figure 4. PG(4, 1) =< 4, 3, 2, 1 > is the shortest path from vertex 4 to vertex 1. Path < 4, 6, 1 > is the detour from vertex 4 to vertex 1 if

(7)

edge (4, 3) is removed. Path < 3, 5, 1 > is the detour from vertex 3 to vertex 1 if edge (3, 2) is removed. Path < 2, 5, 1 > is the detour from vertex 2 to vertex 1 if edge (2, 1) is removed. The detour-critical edge in PG(4, 1) is not edge (4, 3) or edge (2, 1) but edge (3, 2) since dG−(3,2)(3, 1) − dG(3, 1) = 600 − 200 = 400 is greater than dG−(4,3)(4, 1) − dG(4, 1) = 500 − 300 = 200 and dG−(2,1)(2, 1) − dG(2, 1) = 200 − 100 = 100.

The algorithm for finding detours, as well as determining the detour-critical edges, is important from the viewpoint of network management. Due to a sudden edge failure from some vertex, the message must be retransmitted through a detour from the vertex adjacent to the faulty edge.

Suppose that we have several networks. Each network is connected and contains at most n vertices, where 3 ≤ n ≤ 100. Assume now that you are hired to serve as a network administrator and have to determine the maximum distance increment caused by a detour-critical edge of a given shortest path for each network.

### Input

: The input file consists of several test cases. The first line contains an integer indicating the number of test cases. Each test case starts with a positive integer n, where 3 ≤ n ≤ 100. The following n lines represent the adjacency matrix of a network.

An adjacency matrix of a network G with n vertices, denoted by A(G) = [wu,v], is an n × n matrix such that wu,v > 0 if (u, v) is an edge of G, and wu,v = 0 otherwise, where wu,v in a nonnegative integer. Note that any two elements in each line of an adjacency matrix are separated by a space. The last line of each test case represents the sequence of vertices in a given shortest path in which there is also a space between two vertices.

Note that the first and the last vertices denote the source and the destination vertices, respectively. For example, the adjacency matrix of the graph in Figure 4 is shown in test case 3 of the sample input.

### Output

: For each test case, output the maximum distance increment caused by the detour-critical edge of the given shortest path in one line.

(8)

### Sample Input

3 3

0 10 20 10 0 10 20 10 0 3 2 1 4

0 10 10 30 10 0 30 0 10 30 0 10 30 0 10 0 4 3 1 2 6

0 100 0 0 100 200 100 0 100 0 100 400 0 100 0 100 500 0 0 0 100 0 500 300 100 100 500 500 0 0 200 400 0 300 0 0 4 3 2 1

20 30 400

(9)

### Input File: pc.dat

Let A be an array of N , 1 < N ≤ 50000 and N is even, integers. We use A[i] to denote the ith element of the array. Hence the array contains elements A[0], A[1] · · · A[N − 1]. Each element of A is a nonnegative integer in the range of 0 through 9972. Given two integers x and y, let (x mod y) be the integer that is the remainder of y dividing x. It happens that

A[i] = (a1∗ i2+ a2∗ i + a3) mod 9973

for some integers a1, a2, and a3. We know 1 ≤ ai ≤ 50000 for i = 1, 2, 3.

For example, if N = 6, a1 = 1, a2 = 1, and a3 = 1, then we have the following:

i 0 1 2 3 4 5

A[i] 1 3 7 13 21 31

There are three additional arrays S, E and R. Each of the three arrays has M , 1 ≤ M ≤ 50000, integers. We know 1 ≤ S[i] ≤ E[i] ≤ N . It happens that

S[i] = (s1∗ i2+ s2∗ i + s3) mod (N/2) and

E[i] = S[i] + [(e1∗ i2+ e2∗ i + e3) mod (N/2)].

Assume 1 ≤ si, ei ≤ 50000 for i = 1, 2, 3. We also know

R[i] = min{A[S[i]], A[S[i] + 1], . . . , A[E[i]]}

for each i where 0 ≤ i ≤ M − 1. Your task is to find the smallest j such that R[j] = max{R[0], R[1], . . . , R[M − 1]}.

For example, if A is given as the above example, M = 3, s1 = 1, s2 = 1, s3 = 1, e1 = 1, e2 = 1, and e3 = 1, then we have the following:

(10)

i 0 1 2 S[i] 1 0 1 E[i] 2 0 2 R[i] 3 1 3

Hence max{R[0], R[1], R[2]} = 3 and R[0] has the smallest index with its value equaling 3. Thus we output 0.

### Input

: The first line contains the number of test cases w. Then the w test cases are listed one by one. Each test case is listed as follows in one line with a space between two integers: N , a1, a2, a3, M , s1, s2, s3, e1, e2, e3.

### Output

: For each test case, output the smallest value j such that R[j] = max{R[0], R[1], R[2], . . . , R[M − 1]} in one line.

(11)

### Sample Input

1

6 1 1 1 3 1 1 1 1 1 1

0

(12)

### Input File: pd.dat

Referring Figure 5, a tag tree is a hierarchical representation of a 2-dimensional array (2k×2k, k is an integer and 2 ≤ k ≤ 20) of nonnegative values, where successively reduced resolutions form a tree. Note that, for an n × n array, the indices of this array are from 0 to n − 1. The value q`(i, j) at every created node of the tree is the minimum value of its four children q`+1(2i, 2j), q`+1(2i, 2j + 1), q`+1(2i + 1, 2j), and q`+1(2i + 1, 2j + 1), where `, 0 ≤ ` ≤ k, is the level index and i and j are the indices of the 2-dimensional array. The 2-dimensional array at the lowest level is the input array.

3

2 2 2

4

2 2 2 2

2 3 4

4

2 2

2-dimensional input array nodes internal

created





1 0 0 q2

= ) , (

3 0 1 q2

= ) , (

2 0 2 q2

= ) , ( 1

0 0 q0

= ) , (

1 0 0 q1

= ) , (

2 0 1 q1

= ) , (

Figure 5: A tag tree.

The tag tree will be coded into a sequence of bits using the rules described below.

Once a tag tree is constructed, we associate each node with an upgrading value, c`(i, j), which is initialized to zero. The upgrading value of a node is updated while the node is coded. Coding starts at the top node, i.e., the one with the level index 0, and a child cannot be coded until its parent is coded. While coding a node, a zero bit is output to indicate that its upgrading value c`(i, j) is less than its q`(i, j) and then c`(i, j) is increased by one. A one bit is output to indicate that q`(i, j) and c`(i, j) are equal.

(13)

After a node is coded, the upgrading values of all its descendent nodes which have smaller upgrading values are changed to the upgrading value of the coded node. The coding process will be continued until all nodes in the tag tree are coded.

For example, in the following coding is started from the top node which has q0(0, 0) = 1 and c0(0, 0) = 0. Since c0(0, 0) < q0(0, 0), we output a zero bit. Next, we increase c0(0, 0) by 1 and find that c0(0, 0) = q0(0, 0), so we output a one bit. Thus, the output bits result from coding top node are 01. Once q0(0, 0) is coded, the upgrading values of all its descendent nodes with smaller upgrading values are changed to 1 as in Figure 6(a).

c1(0,0)

=1 c1(1,0)

=1 c1(0,1)

=1 c1(1,1)

=1 c0(0,0)

=1

c2(0,0)

=1 c2(1,0)

=1

=1 =1

c2(2,0)

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

(a)

c1(0,1)

=1 c1(1,1)

=1

c2(1,0)

=3

=1 =1

c2(2,0)

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

(d)

c1(0,0)

=1 c1(1,0)

=1 c1(0,1)

=1 c1(1,1)

=1

c2(0,0)

=1 c2(1,0)

=1

=1 =1

c2(2,0)

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

(b)

c1(1,0)

=2 c1(0,1)

=1 c1(1,1)

=1

=1 =1

c2(2,0)

=2 =2

=2 =2

=1 =1

=1 =1

=1 =1

=1 =1

(e)

c1(1,0)

=1 c1(0,1)

=1 c1(1,1)

=1

c2(0,0)

=1 c2(1,0)

=1

=1 =1

c2(2,0)

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

=1 =1

(c)

c1(0,1)

=1 c1(1,1)

=1

c2(0,0) =1

c2(1,0) =3

=1 =1

c2(2,0)

=2 =2

=2 =2

=1 =1

=1 =1

=1 =1

=1 =1

(f) c1(0,0) =1

c1(1,0) =2

c2(0,0) =1

c2(1,0) =3 c1(0,0)

=1

c2(0,0) =1 c0(0,0) =1

c0(0,0) =1

c0(0,0) =1 c1(0,0) =1 c0(0,0) =1 c0(0,0)

=1

c1(1,0)

=1

c1(0,0) =1

*

* *

* *

*

*

* *

*

*

*

* *

*

Figure 6: An example of coding a tag tree.

We mark the coded nodes in Figure 6(b)-(f) by an qq. Next, we code q1(0, 0). We have c1(0, 0) = q1(0, 0) = 1. A one bit is output and q1(0, 0) is coded. The associated upgrading values of its descendant nodes are updated again according to the updating rule (see Figure 6(b)). We continue coding q2(0, 0). A one bit is output for the node because c2(0, 0) = q2(0, 0) (see Figure 6(c)). So, till now, we code q0(0, 0), q1(0, 0), and q2(0, 0) with 0111.

(14)

Next, that we code q2(1, 0) which is 3. It is not necessary to code its ancestors again. Its ancestors q1(0, 0) and q0(0, 0) have already been coded. Thus, we can code q2(1, 0) directly. Its output code will be 001 since c2(1, 0) is increased twice before equal to q2(1, 0) (see Figure 6(d)).

Continue this example. Assume that we are going to code q2(2, 0) which is 2. We have to code its parent q1(1, 0) first since it is not coded yet. Its output code is 01 and the related upgrading values are updated as in Figure 6(e). Back to code q2(2, 0), only a one bit is output (see Figure 6(f)).

### Input

: The first line contains a positive integer N , ≤ 10, indicating the number of test cases. In each test case, the first line contains an integer k indicating that the array size is 2k× 2k. Then, the following 2k lines represent a 2k× 2k array. The rows of this 2k× 2k array are listed line by line. Each row contains 2k nonnegative integers separated by a space.

### Output:

The number of bits used to code the input array in one line for each test case.

(15)

### Sample Input

3 2

1 3 2 3 2 2 2 4 2 2 2 2 2 3 4 4 2

2 1 1 4 1 3 2 3 1 1 3 2 2 1 3 5 3

4 1 3 2 5 2 1 2 1 1 3 4 1 1 3 2 3 3 2 1 2 4 1 2 4 2 4 1 2 3 4 1 1 2 3 2 4 4 1 2 3 2 3 2 4 4 2 4 4 5 1 1 1 1 3 3 3 1 2 3 2 3 4 2

37 38 155

(16)

### Input File: pe.dat

Isomorphism is the problem of testing whether two graphs are really the same. Suppose we are given a collection of graphs and must perform some operation on each of them.

If we can identify which of the graphs are duplicate, they can be discarded so as to avoid redundant work.

First we have to explain what is meant when we say two graphs are the same.

Two labeled graphs G1 = (V1, E2) and G2 = (V2, E2) are identical when we can find a mapping f of the vertices of G1 to the vertices of G2 such that (x, y) is an edge of G1 if and only if (f (x), f (y)) is an edge of G2. Such a mapping is called an isomorphism.

No efficient algorithm is known for the general graph isomorphism problem, but the problem is easier to determine whether two trees are isomorphic to each other. In Figure 7, it is not hard to verify that tree T1 is isomorphic to tree T3, but T1 is not isomorphic to T2.

T2 2

3 6

5 1

4 7

T1 2 7

1

4 6

5 3

T3 5 4

1

7 3

2 6

Figure 7: Three nonrooted root trees.

You are given a collection of k trees C = {T1, T2, . . . , Tk} such that each Ti has exactly n nodes. The objective of the problem is to partition these trees into isomorphic (equivalent) classes such that any two trees within the same isomorphic class are isomorphic to each other.

A naive method of enumerating all possible mapping functions would require gen- erating all possible n! different mappings. What resulted is a very time-consuming

(17)

O(n!) time algorithm just to test two trees. You need to figure out a somehow clever way for solving the problem.

### Input

: A collection of k (n-node) trees C = {T1, T2, . . . , Tk}. The inputs are just a list of integers. The first 2 integers (in a single line) represent the number of trees, k, and the size of each tree, n. Note that k can be as large as 150 and n can be as large as 100. After the two integers, there will be k lines representing the edge sets for each tree Ti; each line contains exactly n − 1 pairs of integers, representing the n − 1 (directed) edges of each tree. Thus, there are totally 2n − 2 integers for each tree, and the total input will be 2k(n − 1) integers except the first two parameters. Each tree is indexed by their appearance ordering; that is, the first line represents the tree T1, the second line is T2, . . . , etc, and the last (kth) line is just Tk.

### Output

: For the given collection of trees, partition these trees into isomorphic (equivalent) classes such that any two trees within the same isomorphic class are isomorphic to each other. For each isomorphic class, output the indices of these iso- morphic trees in a line. Suppose that there are m isomorphic classes, you need to print out m lines. For example, a line

t1 = t2 = · · · = t`;

represents an isomorphic class of size ` such that two trees Tti and Ttj, 1 ≤ i, j ≤ `, are isomorphic to each other. For each line, output indices of those isomorphic trees in increasing order; that is, t1 < t2 < · · · < t`. Further, print out these m isomorphic classes by their increasing lexical ordering; that is, by the ordering of their first indices.

For example, suppose that there are 4 isomorphic classes {4, 2, 7}, {5, 1, 3}, {8, 9}, {6}.

The output shall be

1 = 3 = 5 ; 2 = 4 = 7 ; 6 ;

8 = 9 ;

(18)

### Sample Input

3 7

7 2 7 1 7 6 2 3 1 4 6 5 7 2 7 1 2 3 1 4 1 5 5 6 4 3 3 2 4 1 1 7 5 6 4 5

1 = 3 ; 2 ;

(19)

### Input File: pf.dat

Trees are used to represent the evolutionary relationship of species. An evolutionary tree is a edge-weighted tree with each leaf representing one species. The distance between two leaves on the tree represents the dissimilarity of these two species. An important issue in computational biology is to construct the evolutionary tree from the observed dissimilarities.

Let N = {1..n}. An n × n matrix M is a metric over N if it is symmetric, nonneg- ative, and M [i, j] + M [j, k] ≤ M [i, k] for any i, j, k ∈ N (i.e., triangle inequality). A metric is a tree metric if it can be realized by a tree, i.e., there exists an edge-weighted tree T such that

1. the leaf set is N ;

2. the weight of each edge is nonnegative;

3. and dT(i, j) = M [i, j] for any i, j ∈ N , where dT(i, j) is the shortest path length between i and j on the tree T .

For example, the following matrix is a tree metric. The corresponding tree is given in Figure 8.

M =

0 5 9 12 8 5 0 8 11 7

9 8 0 5 1

12 11 5 0 4

8 7 1 4 0

The size of a tree is defined to be the total weight of the tree edges. For a tree metric, it has been shown that the tree size is unique, i.e., it is impossible to find two trees of different sizes realizing the same tree metric. Your task is to design a program to compute the tree sizes of the given tree metrics. The following simple example may be helpful. For the case of only two species, the tree has only one edge and the tree

(20)

3

2

5 0 4

1 1

2 3

5 4

Figure 8: An evolution tree.

size is just the distance between the two species. Let us consider the case of three species a, b, and c. Let T be the corresponding tree. Since T has three leaves, there is an internal node x. By definition, the path length dT(a, b) = M [a, b]. Since x is a vertex on the path between a and b, all we need to do is to determine the weight (length) of edge (x, c). Let w(x, c) denote the weight of edge (x, c). We have

w(x, c) + w(x, a) = M [a, c], w(x, c) + w(x, b) = M [b, c], and w(x, a) + w(x, b) = M [a, b].

Therefore, w(x, c) = (M [a, c] + M [b, c] − M [a, b])/2.

### Input

: The input file consists of several test cases. The first line of each test case is a positive integer n, 2 < n < 30. The following n − 1 lines represent the upper triangle of the tree metric, but the diagonal is not included. Each line is for one row, and elements are separated by spaces. All the elements are nonnegative integers less than 100. The last case is followed by a q0q to indicate the end of input. You may assume that the test data are all tree metrics, and it is not necessary to check them.

Furthermore, the size of a tree is the sum of all integers in the test case except the integers in the first line of the test case.

### Output

: For each test case, output the tree size in one line.

(21)

### Sample Input

5

5 9 12 8 8 11 7 5 1 4 4

15 36 60 31 55 36 0

15 71

(22)

### Input File: pg.dat

In a mobile Packet Radio (PR) network, intermediate PR’s are used to repeat a message so that it can be transferred from a source to its destination. Each PR has a limited broadcasting range whose boundary is a circle. Each PR moves at a constant speed in the plane. The speed of a moving object in the plane is given by a vector (v1, v2). Here v1 is the speed in the x-coordinate direction, and v2 is the speed in the y-coordinate direction. One unit of time is a second, one unit of length is a meter.

For example, if an object is at position (1, 2) at time 0, and the speed of the object is (−2, 3), then after 1 second the object is at position (1 + (−2) × 1, 2 + 3 × 1) = (−1, 5), and after 2 seconds the object is at position (1 + (−2) × 2, 2 + 3 × 2) = (−3, 8).

Once a PR broadcasts a message, the message reaches all the PR’s within its broadcasting range (including the broadcasting PR itself) immediately (i.e., with 0 time delay). Once a PR receives a message, it can either ignore the message, or broadcast the message, according to instructions. If the PR broadcasts the message, it will do it exactly 1 second after receiving it.

Given a set of PR’s, and a request to transfer a message from a source PR to a destination PR, you are asked to design a program to find a quickest way to transfer the message from the source to its destination. Suppose the request is made at time t0. Then the source PR can broadcast the message at time t0+ 1. Each broadcasting is counted as 1 step. In particular, if a PR broadcasts the message k times, then it is counted as k steps. Your program should calculate how many steps are needed (in an quickest way) to transfer the message from the source PR to its destination PR.

### Input

: The first line of the input file contains an integer n, n ≤ 100, which represents the number of test cases.

Each test case starts with a line containing an integer m, 2 ≤ m ≤ 100, which represents the number of PR’s in this test case. The next m lines are information of these m PR’s. The PR’s are numbered 1, 2, · · · , m, and the ith line are information of

(23)

the ith PR. The information for each PR is a sequence of 5 real numbers: a, b, c, d, e, and each of the 5 numbers is in the range from −100000 to 100000 and has at most 8 digits after the decimal point. The meaning of the reals are as follows: At time 0, the PR lies at point (a, b). The speed of the PR is (c, d). The broadcasting range of the PR is a disk of radius e. After the m lines, which contain information of the PR’s, the next line contains three integers u, v, and w. It means that the request is to transfer a message from the uth PR to the vth PR, and the request is made at time w. There is a space between any two numbers in the same line.

### Output

: If the message can be transferred to its destination in k steps, then the output is the integer k. If the message can never be transferred to its destination, then the output is the letter E.

(24)

### Sample Input

2 2

0 0 1 1 5 1000 0 -1 1 10 1 2 0

3

0 0 1 1 15

1000 500 -1 0 20 -100 -100 0 1 25 1 3 3

498 E

(25)

### Input File: ph.dat

A (m, n) threshold scheme is a method which allows a secret information K to be divided into n shadows Si for 1 ≤ i ≤ n in such a way that any m, m ≤ n, or more shadows can recover the secret information K, but m − 1 or fewer shadows can not.

Threshold schemes have the advantage of distributing an important privilege in many applications, such as access control, launching a missile, opening a bank vault, or even opening a deposit box. A well-known threshold scheme, Shamir’s (m, n) threshold scheme, works as follows:

Without loss of generality, we assume that K is a positive integer which is smaller than P , where P is a prime number. To divide K into n shadows Si for 1 ≤ i ≤ n, we pick a random m − 1 degree polynomial f (x) = am−1xm−1 + am−2xm−2 + ... + a1x + K(mod, P ), where a1, ..., am−2, and am−1 are random integers which are larger than or equal to 0, and less than P . Note that am−1 6= 0. These n shadows are computed by S1 = f (1)(mod, P ), ..., Si = f (i)(mod, P ), ..., Sn = f (n)(mod, P ). It is obvious that any m shadows can uniquely determine the f (x) and hence obtain the secret information K.

Consider, for example, a rich man with nine sons kept his property in a strong room from stealing. The strong room was controlled by a digital master key K, 0 < K < 65521. When he was alive, he used Shamir’s (5, 9) threshold scheme with P = 65521 to share the master key K with his nine sons. The ith son was given the shadow Si = f (i)(mod, 65521) for 1 ≤ i ≤ 9.

After the rich man died, all of his sons met and decided whether they should open their father’s strong room or not. They inputted their shadows to a computer in which a program is responsible for recovering the master key. If one agrees to open, he inputs his correct shadow; otherwise, he inputs a forged shadow (a random number) instead of the correct shadow. Assume that the number of forged shadows is less than or

(26)

equal to 2. Now, you are asked to design a program for computing the master key and showing who agrees to open.

(27)

### Input

: The first line of the input file contains an integer q, q ≤ 5, which represents the number of test cases. Then, the cases are listed line by line. In each line, there are nine integers, separated by a space, which are the shadows inputted to the program in the order of S1 S2 S3 S4 S5 S6 S7 S8 S9, respectively, of test case t, t = 1, 2, . . . , q.

### Output

: Print the master key K and who agrees to open in increasing order, sepa- rated by a space, in line t for t = 1, . . . , q.

(28)

### Sample Input

3

15581 8818 43370 1705 557 63321 54532 7470 58639 49653 16589 16052 43258 50121 10785 52661 63302 18008 38759 25341 45629 54400 5123 42161 29892 11356 11692

### Output for the Sample Input

22331 1 2 3 4 5 6 7 8 9 11220 2 4 5 6 7 8 9 55555 1 3 4 5 6 7 8 9

(29)

### Input File: pi.dat

Tasks in real-time systems must satisfy certain timing constraints. Some real-time tasks must produce outputs in regular or even constant intervals so as to meet the safety concerns and/or to provide smooth operations. This is important for real-time systems such as those used to transmit synchronized audio and video data, or those used to control safety-critical devices. For example, multimedia conferencing systems must transmit and present video information and make sure that the inter-arrival time between video frames is always less than 33 mini seconds. Avionics systems must constantly monitor engine status and decide the amount of fuel to be injected in the next cycle. Robot arms need to move smoothly or synchronously. Unpredictable output timings, or jitters, are undesirable in these applications.

One way to ensure less output jitters is to make sure that the temporal distance between any two consecutive executions of a task is always less than a well-defined time interval. Such systems are called Distance-Constrained Task System. In a distance- constrained task set T = {T1, T2, . . . , Tn}, every task Ti consists of an infinite sequence of jobs Ji1, Ji2, Ji3, · · · . Task Ti has an execution time ei and a temporal distance constraint ci. The temporal distance between two jobs of a task is defined to be the difference of the finish times of these two jobs. Let fij denote the finish time of job Jij, for 1 ≤ i ≤ n and j ≥ 1. The distance between Jij and Ji,j+1 is defined to be fi,j+1− fij. The distance constraint ci requires that for 1 ≤ j < n, fi,j+1− fij ≤ ci. Moreover, the density is defined to be the summation of execution time over distance constraint for all tasks, X

i

ei/ci.

Let A = {a1, a2, . . . , an} be an instance of the distance constraints of n tasks, the distance constraint of task Ti is ai, and assume that a1 ≤ a2 ≤ . . . ≤ an. Most of the pinwheel algorithms use a specialization technique to find a corresponding multiset B

= {b1, b2, . . . , bn} such that ∀i, bi ≤ ai. Since B is more strict than A in terms of distance constraints, if we can make sure that B is schedulable, A is schedulable as

29

(30)

well, where a multiset is a set may have more than one member with the same value.

It has been shown that if B consists solely of multiples of a single number then as long as the density is less or equal to 1, B is schedulable.

For example, B = {3, 3, 6, 6} with one unit execution time can be scheduled as “J1,1, J2,1, J3,1, J1,2, J2,2, J4,1” repeatedly. Note that the distances of jobs for task T1, T2, T3 and T4 are 3, 3, 6, 6 respectively and its density is 1

3 +1 3+ 1

6+1

6 = 1. If A

= {3, 4, 6, 7}, we can use the same schedule to meet its distance constraints.

Definition: Let S be a set of positive real numbers. We say that A is specialized to B with respect to S based on an integer g, or A →gS B, if every ai ∈ A is reduced to bi = xgj for some x ∈ S and integer j ≥ 0 such that , ∀i, bi ≤ ai. 

Single-number reduction has been studied as a class of pinwheel specialization tech- niques such that A →gS B, where |S| = 1. For example, {3, 4, 6, 7} →{3}2 {3, 3, 6, 6}.

Since the density after specialization is increased, the goal of these specialization tech- niques is to minimum the density increase. If none of the density after specialization is less or equal to 1, the distance constraint task set is not schedulable.

### Input

: All the input numbers are positive integers, < 500000, separated by a space or new line. The first line is the number of distance constraint task sets. Then, the task sets are listed set by set. Each task set is listed by a line of the number of tasks,

≤ 100, and lines of task execution time and period pairs, execution time < period. The periods are not sorted and are different in a task set. We use the periods as distance constraints and all task sets are schedulable.

### Output

: Let g = 2, for each task set, find and print out the smallest integer distance constraint of T1 such that after pinwheel specialization the distance constraints are all integers and the density increase is minimized.

30

(31)

### Sample Input

3 4 1 3 1 4 1 6 1 7 3 1 4 2 30 5 12 2

1 123456 1 456123

3 3 114030

31

(32)

### Input File: pj.dat

There are N , 1 ≤ N ≤ 1, 000, rectangles in the 2-D xy-plane. The four sides of a rectangle are horizontal or vertical line segments. Rectangles are defined by their lower-left and upper-right corner points. Each corner point is a pair of two non- negative integers in the range of 0 through 50,000 indicating its x and y coordinates.

Each rectangle cuts the ( already cutted) 2-D xy-plane into small pieces. Therefore, all N rectangles will cut the 2-D xy-plane into a collection of small pieces. Some of these small pieces are rectangles. Assume that all of those small rectangles are colored by green color (the color of the original 2-D xy-plane is white.). Please report the total area colored by green color in the 2-D xy-plane

Example: Consider the following three rectangles:

rectangle 1: < (0, 0) (4, 4) >, rectangle 2: < (1, 1) (5, 2) >, rectangle 3: < (1, 1) (2, 5) >.

The total area of the green area is 11.

### Input

: The input consists of multiple test cases. A line of 4 −1’s separates each test case. An extra line of 4 −1’s marks the end of the input. In each test case, the rectangles are given one by one in a line. In each line for a rectangle, 4 non-negative integers are given. The first two are the x and y coordinates of the lower-left corner point. The next two are the x and y coordinates of the upper-right corner point.

### Output

: For each test case, output the total area of the green area in a line.

32

(33)

### Sample Input

0 0 4 4 1 1 5 2 1 1 2 5 -1 -1 -1 -1 0 0 2 2 1 1 3 3 2 2 4 4 -1 -1 -1 -1 -1 -1 -1 -1

### Output for the Sample Input

11 4

33

Animal or vegetable fats and oils and their fractiors, boiled, oxidised, dehydrated, sulphurised, blown, polymerised by heat in vacuum or in inert gas or otherwise chemically

Milk and cream, in powder, granule or other solid form, of a fat content, by weight, exceeding 1.5%, not containing added sugar or other sweetening matter.

First Taiwan Geometry Symposium, NCTS South () The Isoperimetric Problem in the Heisenberg group Hn November 20, 2010 13 / 44.. The Euclidean Isoperimetric Problem... The proof

Due to a definition of noise factor (in this case) as the ratio of noise powers on the output versus on the input, when a resistor in room temperature ( T 0 =290 K) generates the

• An algorithm for such a problem whose running time is a polynomial of the input length and the value (not length) of the largest integer parameter is a..

• There are important problems for which there are no known eﬃcient deterministic algorithms but for which very eﬃcient randomized algorithms exist. – Extraction of square roots,

[ Composite ] → Tree [ Composite ] receives a significance order of fields and classifies the input list first by the most significant field, and for each bucket classifies the

• Suppose the input graph contains at least one tour of the cities with a total distance at most B. – Then there is a computation path for

➢The input code determines the generator output. ➢Understand the meaning of each dimension to control

• However, inv(A) may return a weird result even if A is ill-conditioned, indicates how much the output value of the function can change for a small change in the

• A function is a piece of program code that accepts input arguments from the caller, and then returns output arguments to the caller.. • In MATLAB, the syntax of functions is

Solution: pay attention on the partial input object each time Problem: larger memory implies more parameters in RNN. Solution: long-term memory increases memory size without

Each unit in hidden layer receives only a portion of total errors and these errors then feedback to the input layer.. Go to step 4 until the error is

The well-known halting problem (a decision problem), which is to determine whether or not an algorithm will terminate with a given input, is NP-hard, but

• If we know how to generate a solution, we can solve the corresponding decision problem. – If you can find a satisfying truth assignment efficiently, then sat is

(b) Write a program (Turing machine, Lisp, C, or other programs) to simulate this expression, the input of the program is these six Boolean variables, the output of the program

• Any node that does not have a local replica of the object periodically creates a QoS-advert message contains (a) its δ i deadline value and (b) depending-on , the ID of the node

•The running time depends on the input: an already sorted sequence is easier to sort. •Parameterize the running time by the size of the input, since short sequences are easier

– One of the strengths of CKC Chinese Input System is that it caters for the input of phrases to increase input speed..  The system has predefined common Chinese phrases, such

• One of the strengths of CKC Chinese Input System is that it caters for the input of phrases to increase input speed.  The system has predefined common Chinese phrases, such

Put the current record with the “smaller” key field value in OutputFile if (that current record is the last record in its corresponding input file) :. Declare that input file to be

; actual input count buffer BYTE count DUP(?) ; holds input chars KEYBOARD ENDS. • Requires a predefined structure to be set up that describes the maximum input size and holds the

We use InGaP/GaAS power HBT process of GCS to design our circuit by matching S-parameter and optimum load for maximum power output in the input port and output port.. In