【模板】Floyd

int n;
int d[MAX_N + 1][MAX_N + 1];

void Floyd()
{
    for(register int k = 1; k <= n; ++k)
    {
        for(register int i = 1; i <= n; ++i)
        {
            for(register int j = 1; j <= n; ++j)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j];
            } 
        }
    }
    return;
}

 

上一篇:NOIP2016换教室


下一篇:5780: 刻录光盘(floyd+找根有顺序)