E. Out of Controls

题目连接:

http://www.codeforces.com/contest/656/problem/E

Description

You are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the longest of them.

Input

The first line of the input contains a single integer N (3 ≤ N ≤ 10).

The following N lines each contain N space-separated integers. jth integer in ith line aij is the length of the edge that connects vertices i and j. aij = aji, aii = 0, 1 ≤ aij ≤ 100 for i ≠ j.

Output

Output the maximum length of the shortest path between any pair of vertices in the graph.

Sample Input

3

0 1 1

1 0 4

1 4 0

Sample Output

2

Hint

题意

给你一个邻接矩阵,然后让你输出其中最大的最短路是多少

但是你不能使用

define

do

for

foreach

while

repeat

until

if

then

else

elif

elsif

elseif

case

switch

这些函数名字

题解:

可以用三目运算符嘛,然后递归的去做就好了。

代码

#include<bits/stdc++.h>
using namespace std; int a[15][15];
int res;
int n;
int get(int x,int y)
{
cin>>a[x][y];
return y==n?(x==n?1:get(x+1,1)):get(x,y+1);
}
int geta(int x,int y)
{
res=max(res,a[x][y]);
return y==n?(x==n?1:geta(x+1,1)):geta(x,y+1);
}
int flyod(int x,int y,int k)
{
a[x][y]=min(a[x][y],a[x][k]+a[k][y]);
y++;
y==n+1?(x++,y=1):0;
x==n+1?(x=1,k++):0;
k<=n?flyod(x,y,k):0;
}
int main()
{
cin>>n;
get(1,1);
flyod(1,1,1);
geta(1,1);
cout<<res<<endl;
}

April Fools Day Contest 2016 E. Out of Controls的更多相关文章

  1. CF #April Fools Day Contest 2016 E Out of Controls

    题目连接:http://codeforces.com/problemset/problem/656/E 愚人节专场的E,整个其实就是个Floyd算法,但是要求代码中不能包含 definedoforfo ...

  2. April Fools Day Contest 2016 D. Rosetta Problem

    D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...

  3. April Fools Day Contest 2016 G. You're a Professional

    G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...

  4. April Fools Day Contest 2016 F. Ace It!

    F. Ace It! 题目连接: http://www.codeforces.com/contest/656/problem/F Description Input The only line of ...

  5. April Fools Day Contest 2016 C. Without Text 信号与系统

    C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...

  6. April Fools Day Contest 2016 B. Scrambled

    B. Scrambled 题目连接: http://www.codeforces.com/contest/656/problem/B Description Btoh yuo adn yuor roo ...

  7. April Fools Day Contest 2016 A. Da Vinci Powers

    A. Da Vinci Powers 题目连接: http://www.codeforces.com/contest/656/problem/A Description The input conta ...

  8. April Fools Day Contest 2014

    April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...

  9. 坑爹CF April Fools Day Contest题解

    H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...

随机推荐

  1. Double类型的数向上取整和向下取整

  2. Codeforces 665E. Beautiful Subarrays (字典树)

    题目链接:http://codeforces.com/problemset/problem/665/E (http://www.fjutacm.com/Problem.jsp?pid=2255) 题意 ...

  3. Linux内核多线程实现方法 —— kthread_create函数【转】

    转自:http://blog.csdn.net/sharecode/article/details/40076951 Linux内核多线程实现方法 —— kthread_create函数 内核经常需要 ...

  4. juery中循环遍历json数组

    var dataList=[]; var stock0={stockcode:"007758",stockname:"商业政7",state:"1&q ...

  5. 当while read line 遇到 ssh

    问题:while read line 中使用ssh只能读取一行? #!/bin/sh while read line do echo $line ssh root@$line "echo 1 ...

  6. ActiveMQ-如何使用JMS API?

    JMS编程模型 JMS定义了Java中访问消息中间件的一组接口,主要包括ConnectionFactory.Connection.Session.Destination.MessageProducer ...

  7. 利用Google API生成二维码

    什么是二维码:二维码是二维条形码的一种,可以将网址.文字.照片等信息通过相应的编码算法编译成为一个方块形条码图案,手机用户可以通过摄像头和解码软件将相关信息重新解码并查看内容.读取方式:利用30万画素 ...

  8. JSP基础与提高(一).md

    JSP基础 JSP的由来 1.1. 为什么有JSP规范 Servlet技术产生以后,在使用过程中存在一个很大的问题,即为了表现页面的效果而需要输出大量的HTML标签,这些标签在Servlet中表现为一 ...

  9. 小甲鱼Python笔记(类)

    类和对象 类的构造方法 def __init__(): 1 class People: 2 def __init__(self,name): 3 self.name = name 注意:在构造方法中的 ...

  10. ADO.NET Connection Pooling at a Glance

    ADO.NET Connection Pooling at a Glance Establishing a connection with a database server is a hefty a ...