HDU 1869(最短)


2つの最短パスアルゴリズムの比較:
Dijkstraアルゴリズムの符号化量は:1277 B、使用時:46 MS;
Floydアルゴリズムの符号化量は:808 B、使用時間:62 MS;
#include 
#include 
#include 
using namespace std;
#define INF 0xffffff
#define max 105
int dist[max],map[max][max],n,m;
bool visited[max];
void Dijkstra (int s)
{
    int k=0;
    memset (visited,0,sizeof visited);
    for (int i=0;i>n >>m)
    {
        int a,b;
        for (int i=0;i>a >>b;
            map[a][b] = map[b][a] = 1;
        }
        bool tag = false;
        for (int i=0; i 7)
                {
                    tag = true;
                    break;
                }
            if (tag)
                break;
        }
        if (tag)
            puts ("No");
        else
            puts ("Yes");
    }
    return 0;
}
#include 
#define INF 0xffffff
#define max 101
int dist[max][max],n;
void Floyd ()
{
    for (int k=0;k dist[i][k]+dist[k][j])
                    dist[i][j] = dist[i][k]+dist[k][j];
}
void init ()
{
    for (int i=0;i 7)
                return false;
    return true;
}

int main ()
{
    int m;
    while (~scanf ("%d%d",&n,&m))
    {
        int a,b;
        init ();
        while (m--)
        {
            scanf ("%d%d",&a,&b);
            dist[a][b] = dist[b][a] = 1;
        }
        Floyd ();
        if (fun ())
            puts ("Yes");
        else
            puts ("No");
    }
    return 0;
}