CF1310D.Tourism

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Masha lives in a country with nn cities numbered from 11 to nn . She lives in the city number 11 .

There is a direct train route between each pair of distinct cities ii and jj , where iji \neq j . In total there are n(n1)n(n-1) distinct routes. Every route has a cost, cost for route from ii to jj may be different from the cost of route from jj to ii .

Masha wants to start her journey in city 11 , take exactly kk routes from one city to another and as a result return to the city 11 . Masha is really careful with money, so she wants the journey to be as cheap as possible. To do so Masha doesn't mind visiting a city multiple times or even taking the same route multiple times.

Masha doesn't want her journey to have odd cycles. Formally, if you can select visited by Masha city vv , take odd number of routes used by Masha in her journey and return to the city vv , such journey is considered unsuccessful.

Help Masha to find the cheapest (with minimal total cost of all taken routes) successful journey.

输入格式

First line of input had two integer numbers n,kn,k ( 2n80;2k102 \leq n \leq 80; 2 \leq k \leq 10 ): number of cities in the country and number of routes in Masha's journey. It is guaranteed that kk is even.

Next nn lines hold route descriptions: jj -th number in ii -th line represents the cost of route from ii to jj if iji \neq j , and is 0 otherwise (there are no routes iii \to i ). All route costs are integers from 00 to 10810^8 .

输出格式

Output a single integer — total cost of the cheapest Masha's successful journey.

输入输出样例

  • 输入#1

    5 8
    0 1 2 2 0
    0 0 1 1 2
    0 1 0 0 0
    2 1 1 0 0
    2 0 1 2 0

    输出#1

    2
  • 输入#2

    3 2
    0 1 1
    2 0 1
    2 2 0

    输出#2

    3
首页