#P6714. [CCO 2018] Wrong Answer
[CCO 2018] Wrong Answer
Problem Description
In a contest, you encountered a problem:
There is a complete graph with vertices and weighted edges. You can control two people starting from vertex 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 .
In the next lines, the -th line contains numbers, which are . Here, denotes the edge weight from to .
5
1 2 3 4
10 9 8
7 6
5
Hint
SPJ Scoring Rules
You must ensure that and , 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 and the correct answer is , then you will get a score of .
Translator’s note: For easier scoring, please use 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 , while the wrong code returns , so you get point.
Notes
This problem is translated from Canadian Computing Olympiad 2018 Day 1 T2 Wrong Answer.
Thanks to
Translated by ChatGPT 5