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. xss自动化攻击

    所需工具 [1.xssValidator] [2.phantomjs] [3.xss.js] /** * This is a basic phantomJS script that will be u ...

  2. supervisor之启动rabbitmq报错原因

    前言 今天重启了服务器,发现supervisor管理的rabbitmq的进程居然启动失败了,查看日志发现老是报错,记录一下解决的办法. 报错:erlexec:HOME must be set 找了网上 ...

  3. elasticsearch集群介绍及优化【转】

    elasticsearch用于构建高可用和可扩展的系统.扩展的方式可以是购买更好的服务器(纵向扩展)或者购买更多的服务器(横向扩展),Elasticsearch能从更强大的硬件中获得更好的性能,但是纵 ...

  4. windows安装React Native开发运行环境

    React Native是什么 React Native是facebook开源的一个用于开发app的框架.React Native的设计理念:既拥有Native (原生) 的用户体验.又保留React ...

  5. HTTP 请求 的方法Util

    HTTP请求 的一系列方法总结 /** * *******************************传统请求--开始************************************** ...

  6. gradle-4.1-rc-1-all.zip gradle-4.1-rc-2-all.zip 免费下载(百度网盘)

    今天下载遇到官网不给力,给有需要的你 gradle-4.1-rc-1-all.zip 密码: uyey gradle-4.1-rc-2-all.zip 密码: txhh

  7. alias命令别名

    笔者在看<鸟哥私房菜>时,突然看到这个命令,之前未接触过,故简单记录学习下,具体的大家可参见man手册.功能说明:设置指令的别名.语 法:alias[别名]=[指令名称]参 数 :若不加任 ...

  8. POJ 1386 Play on Words(单词建图+欧拉通(回)路路判断)

    题目链接:http://poj.org/problem?id=1386 题目大意:给你若干个字符串,一个单词的尾部和一个单词的头部相同那么这两个单词就可以相连,判断给出的n个单词是否能够一个接着一个全 ...

  9. hive的窗口函数ntile、row_number、rank

    一.ntile 序列函数不支持window子句 数据准备: cookie1,--, cookie1,--, cookie1,--, cookie1,--, cookie1,--, cookie1,-- ...

  10. 几个python one-liner

    生成斐波那契数列的前10个数,从1开始.若生成前n个,改为range(n-2).代码很简单: List = reduce(lambda x, y: x + [x[-1] + x[-2]], range ...