zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    Juniper路由器
    Juniper交换机维护
    [转载]让你瞬间开悟的图片
    [转载]生命科学-人体生物磁场及特异作用
    NAS与SAN有什么区别?
    使用串口终端安装AIX操作系统
    xml与java代码相互装换的工具类
    mybatis思维导图(二)
    mybatis思维导图(一)
    Spring思维导图(AOP篇)
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5348114.html
Copyright © 2011-2022 走看看