荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: huhaiming (一生只爱她), 信区: Program
标  题: problem B
发信站: 荔园晨风BBS站 (Sat May 24 20:04:33 2003), 站内信件


Equivalence


Time limit: 5 Seconds   Memory limit: 32768K
Total Submit: 0   Accepted Submit: 0

------------------------------------------------------------------------
--------
When learning mathamatics, sometimes one may come to an theorem which
goes
like this:
The following statements are equivalent:

a)......
b)......
c)......

For example, let A be an angle between 0 and 360 degrees, the
following
statements are equivalent:

a)A = 90 degrees;
b)A is a right angle;
c)sin(A) = 1.

Proving such a theorem is usually a difficult task, because you have
to
prove that for any two statements Si and Sj, Si concludes Sj and vise
versa.
Sometimes, proving Si concludes Sj directly is quite difficult so we may
 find
a Sk and prove that Si concludes Sk and Sk concludes Sj. Now given the
difficulty of proving every Si => Sj, you are to calculate the minimal
total
difficulty to prove that the given statements are equivalent.


Input

The input contains several cases. Each case begins with an integer n
(2 <= n <= 6), the number of statements in this case, followed by n
lines,
each contains n integers.

The jth integer of the ith row represents the difficulty of proving Si
=> Sj.
The ith integer of the ith row is always 0 as it's obvious that Si
concludes
Si. All the n * n integers are between 0 and 100, inclusively. Input
is
terminated by EOF.


Output

For each test case, output a line with the minimal difficulty for that
case.


Sample Input

4
0 2 3 4
5 0 7 8
9 10 0 12
13 14 15 0


Sample Output

34


Author: PAN, Minghao



------------------------------------------------------------------------
--------

Submit   Back   Status

------------------------------------------------------------------------
--------

Zhejiang University Online Judge V1.0
--

菩提本无树,明镜亦非台

本来无一物,何处惹尘埃

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.200]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店