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. linux的防火墙管理

    换oricle-linux7系统后,发现iptables的管理方法有不小的改动,记录一下遇到的问题. iptables linux系统已经默认安装了iptables和firewalld两款防火墙管理工 ...

  2. SQL 变量 条件查询 插入数据

    (本文只是总结网络上的教程) 在操作数据库时 SQL语句中难免会用到变量 比如 在條件值已知的情況下 INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值 ...

  3. ubuntu10.04 svn安装方法

    ubuntu10.04 svn安装方法:sudo apt-get install subversion sudo apt-get install libneon27-dev orsudo apt-ge ...

  4. pycharm双击无响应,打不开问题解决办法

    之前好好的pycharm,突然双击打不开了,怎么办? 亲测有效方案: 第一步:进入如下路径,找到cmd.exe,右键选择“以管理员身份运行”: 第二步:在打开的cmd窗口中,输入 netsh wins ...

  5. shell脚本自带变量的含义

    $0 Shell本身的文件名 $1-$n 添加到Shell的各参数值.$1是第1参数.$2是第2参数… $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process ...

  6. linux系统性能排查命令

    [top] 命令可以动态查看当前系统的资源情况,以及占用资源的命令列表 用法: - ctrl + c / q : 停止此命令运行 - c : 展示完整的命令 - [top -bn1]:可以不动态的展示 ...

  7. python-unittest学习2--生成报告

    上个是小练习  ,这次将unittest模块化一下,也就是吧用例放在case目录下,start放在bin目录下面 -------------------start------------------- ...

  8. leetcode 之Sum系列(七)

    第一题是Two Sum 同样是用哈希表来做,需要注意的是在查打gap是要排除本身.比如target为4,有一个值为2,gap同样为2. vector<int> twoSum(vector& ...

  9. 【转载】移动开发中的上下左右滑动插件jquery.swipe.js

    原文地址http://blog.csdn.net/pvfhv/article/details/3449803/# 源码: (function($) { var old = $.fn.swipe; $. ...

  10. IntelliJ IDEA 创建maven项目一次后,然后删除,再次保存到此目录下,提供此目录已经被占用的问题。

    -------------------2017-02-14补充: 你看既然是创建过一次 不允许再次创建了,那么请问 第一次创建的 跑哪里去了,不仅仅是保存到了你指定的目录里,其实也默认安装到了 mav ...