April Fools Day Contest 2016 E. Out of Controls
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的更多相关文章
- CF #April Fools Day Contest 2016 E Out of Controls
题目连接:http://codeforces.com/problemset/problem/656/E 愚人节专场的E,整个其实就是个Floyd算法,但是要求代码中不能包含 definedoforfo ...
- April Fools Day Contest 2016 D. Rosetta Problem
D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...
- 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 ...
- 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 ...
- April Fools Day Contest 2016 C. Without Text 信号与系统
C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...
- April Fools Day Contest 2016 B. Scrambled
B. Scrambled 题目连接: http://www.codeforces.com/contest/656/problem/B Description Btoh yuo adn yuor roo ...
- 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 ...
- April Fools Day Contest 2014
April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...
- 坑爹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 ...
随机推荐
- 深入理解Spring系列之四:BeanDefinition装载前奏曲
转载 https://mp.weixin.qq.com/s?__biz=MzI0NjUxNTY5Nw==&mid=2247483835&idx=1&sn=276911368d4 ...
- keypress 、keydown、keyup后触发回车
1.keypress .keydown.keyup的区别 keypress表示键盘按下的全过程,只有按下任意字母数字键(后退.删除等系统功能键无效)时才触发,捕获到的keyCode区分大小写 keyd ...
- 《STL源码剖析》读书笔记
转载:https://www.cnblogs.com/xiaoyi115/p/3721922.html 直接逼入正题. Standard Template Library简称STL.STL可分为容器( ...
- tyvj P1050 最长公共子序列
题目链接:http://tyvj.cn/p/1050 题解: 裸题,只是为了测试LCS模板写对没有…… #include<cstdio> #include<cstring> # ...
- [转载]C++多态技术
摘自: http://www.royaloo.com/articles/articles_2003/PolymorphismInCpp.htm http://blog.sciencenet.cn/bl ...
- docker swarm join 报错
[peter@minion ~]$ docker swarm join --token SWMTKN-1-3mj5po3c7o04le7quhkdhz6pm9b8ziv3qe0u7hx0hrgxsna ...
- java基础2 判断语句:if ... else 语句和 switch 语句
一.if ... else 判断语句 1.if ... else 判断语句的格式 1.1.格式一 if(判断条件){ 执行不满足条件的语句 } 1.2.格式二 if(判断语句){ 满足条件的语句 }e ...
- 2.rabbitmq 工作队列
1. 生产者 #coding:utf8 import pika import json import sys message = ''.join(sys.argv[1:]) or "hell ...
- 在go中连接mysql
5.访问数据库 5.1 database/sql接口 5.2 使用MySQL数据库 5.3 使用SQLite数据库 5.4 使用PostgreSQL数据库 5.5 使用Beego orm库进行ORM开 ...
- Numpy存取文件
来自 Python科学计算 http://hyry.dip.jp/tech/book/page/scipy/numpy_file.html NumPy提供了多种存取数组内容的文件操作函数.保存数组数据 ...