ACM ICPC Kharagpur Regional 2017

ACM ICPC Kharagpur Regional 2017

A - Science Fair

Title description : Given a graph with \(n\) points and \(m\) undirected edges, some two points are marked as \(S, T\) , and the other marked \(p\ ) A dot indicates that there is one student. Now the school bus starts from \(S\) , picks up the students on the list to \(T\) , and each student appears on the list with equal probability. one student, that student will also get on the bus. Each student has a \(talk\) value, and the cost of the school bus to complete the task is: the product modulo \(10^9+7\) of the actual student's \(talk\) value when it reaches \(T\ ) and the path length and. For each list, the school bus will choose the minimum cost to go, and find the expected cost.

solution
finds the shortest distance between \(p\) points without passing other \(p\) points, and the distance with \ ( S , T\) (without passing other \(p\) points), Then the state pressure finds the shortest distance of these students with \(sett\ ) when reaching \(T\) . Then press \(dp\) to find the minimum cost of picking up \(sett\) these students.

Time complexity: \(O(2^p*p+p^p*m)\)

B - Black Discs

Description of the topic : Give \(n\) semicircles with a diameter on the \(x\) axis (the semicircle is above the \(x\) axis), and each time you ask a circle in the first quadrant, ask the The area of ​​the circle and the semicircle intersect.

C - Uniform Strings

Title description : Given a \(01\) string, find the number of different adjacent characters, and determine whether there are no more than two.

solution
simulation.

Time complexity: \(O(string length)\)

D - SAD Queries

Topic description : Given \(K\) sequences, each query specifies two sequences \(P, Q\) , find \(\sum_{i=1}^{p} \sum_{j=1}^ {q} |P_i-Q_j|\)

Solution
brute force, enumerating shorter sequences per query, and bisecting longer sequences.

Time complexity: will not count

E - Chef and XOR Queries

Topic description : Given a tree, there are edge weights on the edges (unknown). There are two operations: 1. Given \(x, y, v\) , determine whether the \(XOR\ ) of the simple path from \ (x\) to \(y\) according to the known information may be \(v \) , if it is, the value of \(XOR\) is treated as \(v\) , otherwise it outputs 'WA', 2. Ask for the value of \(XOR\) for a simple path of \ (x, y\) , or unknown output \ (-1\) .

The shape of the solution
tree is useless. The weighted union is used to record the \(XOR\) value from each point to the root of the union, and the operation \(1\) is equivalent to merging the union.

Time complexity: \(O(Q+n)\)

F - Taxi Making Sharp Turns

Title description : Given \(n\) line segments that are connected end to end (the first and the last are not connected), start from the unconnected end of the first line segment and go to the end, and ask whether the corners exceed \ (45^{\circ}\) , if so, ask if it is possible to change the coordinates of a point so that there is no corner that exceeds \(45^{\circ}\) .

solution
simulation.

G - Spam Classification Using Neural Net

Description of the topic : Give the oblique truncated equation of \(n\) straight lines, given an interval \([minX, maxX]\) , operate on each integer point in the interval: substitute \(x\) into For the first straight line, the obtained result is substituted into the second straight line as \(x\) , and so on. Ask if the final result is an even number.

The parity of the solution
result is related to the parity of the initial value, just bring \(0, 1\) into it and calculate it.

Time complexity: \(O(n)\)

H - Non Overlapping Segments

Title description : There are \(n\) line segments on the \(x\) axis, the length of each line segment is \(R\) , and the coordinates of the left end are integers \(x_i\) , now these line segments need to be moved Go to \([0, L]\) (the entire line segment must be inside), and ask how many line segments to move at least.

solution sorts
the line segments by \(x_i\) . Note that \(f[i][j]\) means that the first \(i\) line segments have \(j\) lines that have no kinetic energy to put in how many line segments. Enumerate the previous line segment \(k\) , then \ (\frac{x_i-(x_k+R)}{R}\) line segments can be placed between \(k, i\) . If \(j+f[i][j] \geq n\) , then update answer with \(nj\) .

Time complexity: \(O(n^3)\)

I - Spanning Tree

Title description : There is a graph of \(n\) points, the edge weight is unknown, you can choose \(A, B\) two point sets each time, ask the minimum value of the edge between \(A, B\) , the system returns the minimum value of the edge and the two endpoints of the edge, or does not exist. Find the edge weights of the minimum spanning tree for this graph. The cost of each query is \(|A|\) , the total cost cannot exceed \(10^4\) , and \(|A|+|B|\) cannot exceed \(2*10^6\) .

The solution
maintains connectivity with a union check. Each time the smallest union set \(A\) is found, the complement of \(A, A\) is asked , and the answer is an edge on the spanning tree.

Time complexity: \(O(nlogn)\)

J - Generating A Permutation

Title description : Given \(n, K\) , find a \(n\) arrangement that satisfies \(\sum_{i=2}^{n} max(p_i, p_{i-1})=K \) , output the permutation, or no solution.

The solution
takes \(n=5\) as an example:
54321the smallest is \(14\)
35241 the largest is \(18\)

Obviously, the descending order is the smallest, and the largest number is the largest starting from the \(2\) th bit. Judging by this.
Set the minimum value to \(minv, k-=minv\) , use the array \(cnt\) to remember the contribution of each number to the answer, at the beginning except \(1\) the contribution of each number to the answer is \ (1\) , \(i\) points to \(n\) , \(j\) points to \(2\) , if \(k \geq ij\) , then the contribution of \(i\) adds \( 1\) , the contribution of \(j\) minus \(1\) , and the contribution of a number is at most \(2\) , so \(i--, j++\) ; otherwise \(j++\)
calculates each After the number of contributions, you can fill in the number in the arrangement.

Time complexity: \(O(n)\)

K - Number Game

Title description : Given two numbers \(A, M\) . Start by removing a digit from \(A\) ( \(A\) remains unchanged) to get \(B\) , and then do several operations: each time remove a digit from \(A\) ( \( \ ) (A\) remains unchanged) to get \(C\) , connect \(C\) to the back of \(B\) to get a new \(B\) . Ask how many ways to remove at the beginning, so that the number obtained after several operations is a multiple of \(M\) .

The solution calculates the value
of the digital modulus \(M\) obtained by each removal method, and then explodes ( \(bfs\) ) to find out whether each modulus value can finally become \(0\)

Time complexity: \(O(M^2)\)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939356&siteId=291194637