#P6714. [CCO 2018] Wrong Answer

    ID: 7482 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2018提交答案Special JudgeCCO(加拿大)

[CCO 2018] Wrong Answer

Problem Description

In a contest, you encountered a problem:

There is a complete graph with NN vertices and weighted edges. You can control two people starting from vertex 11 to visit every vertex. You may only move from a smaller-numbered vertex to a larger-numbered vertex. Find the minimum total edge weight.

You took one look and thought it was easy, so you solved it instantly.

However, a contestant’s Python submission caught your attention:

def Solve(N, A):
    # A[i][j] is cost of moving from level i to level j
    # N is the number of levels
    x, y, sx, sy = 1, 1, 0, 0 # Initialize x and y to 1, sx and sy to 0
    for i in range(2, N + 1): # loop from 2 to N
        if sx + A[x][i] < sy + A[y][i]:
            sx += A[x][i]
            x = i
        else:
            sy += A[y][i]
            y = i
    return sx + sy

You immediately realized this is a wrong solution, so you decided to hack it.

Input Format

No input.

Output Format

The first line contains an integer NN.

In the next N1N - 1 lines, the ii-th line contains NiN - i numbers, which are Ai,i+1,Ai,i+2Ai,nA_{i,i+1}, A_{i,i+2} \ldots A_{i,n}. Here, Ai,jA_{i,j} denotes the edge weight from ii to jj.


5
1 2 3 4
10 9 8
7 6
5

Hint

SPJ Scoring Rules

You must ensure that 2N1002 \le N \le 100 and 1Ai,j1001 \le A_{i,j} \le 100, otherwise you will receive no score.

You must ensure the output format is correct, otherwise you will receive no score.

If this wrong code returns XX and the correct answer is YY, then you will get a score of min(25,X4×Y)\lceil \min(25, \frac{X}{4 \times Y}) \rceil.

Translator’s note: For easier scoring, please use 100100 points as the full score in the SPJ.

Sample Explanation

In the official solution, one person goes to the second vertex, and the other person goes to the remaining vertices. The total edge weight is 1+2+7+5=151 + 2 + 7 + 5 = 15, while the wrong code returns 1818, so you get 184×15=1\lceil \frac{18}{4 \times 15} \rceil = 1 point.

Notes

This problem is translated from Canadian Computing Olympiad 2018 Day 1 T2 Wrong Answer.

Thanks to

https://www.luogu.com.cn/user/60864
ing the SPJ.

Translated by ChatGPT 5