Codeforces Round #580 (Div. 1)

Contest Info


Practice Link

Solved A B C D E F
2/6 O O - - - -
  • O through the game
  • Ø After the game by
  • ! I tried but failed
  • - No attempt

Solutions


A. Almost Equal

The meaning of problems:
construct a arranged such that it forms a loop, and any three adjacent numbers and by no more than \ (1 \) .

Ideas:
We have found any adjacent three numbers and differ by no more than \ (1 \) , and the assumption is \ (\?) , Lists the following formula:
\ [\ eqnarray the begin {*} A_1 + + A_3 & A_2 ?? = & \\ a_2 + a_3 + a_4 & = & \\ \ cdots \\ a_ {n - 2} + a_ {n - 1}? + a_n & = & \\ a_n + a_1 + a_2 & = &? \ end {eqnarray *} \]
then there is:
\ [\ the begin {the eqnarray *} | A_1 - A_4 | & \ Leq &. 1 \\ | A_2 - A_5 | & \ Leq &. 1 \\ | A_3 - a_6 | & \ Leq &. 1 \\ | a_4 - a_7 | & \
leq & 1 \\ \ end {eqnarray *} \] then obviously there is \ (a_1, a_4 \) is adjacent to two numbers, \ (A_2, A_5 \) is adjacent to two number, \ (A_3, a_6 \) two adjacent numbers.
So this assignment just fine, and then found \ (n \) is not an even number of times.

B. Shortest Cycle

Meaning of the questions:
There \ (n \) points, any two \ ((i, j) \ ) if \ (i \ & j \ neq 0 \) , then \ ((i, j) \ ) between there is an edge.
Now looking for a minimum ring.

Ideas:
Consider each one, then this is a \ (1 \) is the number of connected components will form a strong, if it is a \ (1 \) the number of points greater than or equal \ (3 \) , then there must be a size \ (3 \) ring.
Otherwise direct violence \ (DFS \) to find the ring can be.

Guess you like

Origin www.cnblogs.com/Dup4/p/11406904.html