codeforces 656 E Out of Controls Floyd

Posted 13rj1115

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 656 E Out of Controls Floyd相关的知识,希望对你有一定的参考价值。

题意:求任意两点的最短路,并输出最大的值

思路:直接Floyd

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
using namespace std;
int d[133][133];
int main()
{
    int i,j,k,n,tp,ans;
    scanf("%d",&n);
    d[0][0]=999999999;
    d[0][1]=999999999;
    d[0][2]=999999999;
    d[0][3]=999999999;
    d[0][4]=999999999;
    d[0][5]=999999999;
    d[0][6]=999999999;
    d[0][7]=999999999;
    d[0][8]=999999999;
    d[0][9]=999999999;
    d[1][0]=999999999;
    d[1][1]=999999999;
    d[1][2]=999999999;
    d[1][3]=999999999;
    d[1][4]=999999999;
    d[1][5]=999999999;
    d[1][6]=999999999;
    d[1][7]=999999999;
    d[1][8]=999999999;
    d[1][9]=999999999;
    d[2][0]=999999999;
    d[2][1]=999999999;
    d[2][2]=999999999;
    d[2][3]=999999999;
    d[2][4]=999999999;
    d[2][5]=999999999;
    d[2][6]=999999999;
    d[2][7]=999999999;
    d[2][8]=999999999;
    d[2][9]=999999999;
    d[3][0]=999999999;
    d[3][1]=999999999;
    d[3][2]=999999999;
    d[3][3]=999999999;
    d[3][4]=999999999;
    d[3][5]=999999999;
    d[3][6]=999999999;
    d[3][7]=999999999;
    d[3][8]=999999999;
    d[3][9]=999999999;
    d[4][0]=999999999;
    d[4][1]=999999999;
    d[4][2]=999999999;
    d[4][3]=999999999;
    d[4][4]=999999999;
    d[4][5]=999999999;
    d[4][6]=999999999;
    d[4][7]=999999999;
    d[4][8]=999999999;
    d[4][9]=999999999;
    d[5][0]=999999999;
    d[5][1]=999999999;
    d[5][2]=999999999;
    d[5][3]=999999999;
    d[5][4]=999999999;
    d[5][5]=999999999;
    d[5][6]=999999999;
    d[5][7]=999999999;
    d[5][8]=999999999;
    d[5][9]=999999999;
    d[6][0]=999999999;
    d[6][1]=999999999;
    d[6][2]=999999999;
    d[6][3]=999999999;
    d[6][4]=999999999;
    d[6][5]=999999999;
    d[6][6]=999999999;
    d[6][7]=999999999;
    d[6][8]=999999999;
    d[6][9]=999999999;
    d[7][0]=999999999;
    d[7][1]=999999999;
    d[7][2]=999999999;
    d[7][3]=999999999;
    d[7][4]=999999999;
    d[7][5]=999999999;
    d[7][6]=999999999;
    d[7][7]=999999999;
    d[7][8]=999999999;
    d[7][9]=999999999;
    d[8][0]=999999999;
    d[8][1]=999999999;
    d[8][2]=999999999;
    d[8][3]=999999999;
    d[8][4]=999999999;
    d[8][5]=999999999;
    d[8][6]=999999999;
    d[8][7]=999999999;
    d[8][8]=999999999;
    d[8][9]=999999999;
    d[9][0]=999999999;
    d[9][1]=999999999;
    d[9][2]=999999999;
    d[9][3]=999999999;
    d[9][4]=999999999;
    d[9][5]=999999999;
    d[9][6]=999999999;
    d[9][7]=999999999;
    d[9][8]=999999999;
    d[9][9]=999999999;
    scanf("%d",&d[0/n][0%n]);
    scanf("%d",&d[1/n][1%n]);
    scanf("%d",&d[2/n][2%n]);
    scanf("%d",&d[3/n][3%n]);
    scanf("%d",&d[4/n][4%n]);
    scanf("%d",&d[5/n][5%n]);
    scanf("%d",&d[6/n][6%n]);
    scanf("%d",&d[7/n][7%n]);
    scanf("%d",&d[8/n][8%n]);
    scanf("%d",&d[9/n][9%n]);
    scanf("%d",&d[10/n][10%n]);
    scanf("%d",&d[11/n][11%n]);
    scanf("%d",&d[12/n][12%n]);
    scanf("%d",&d[13/n][13%n]);
    scanf("%d",&d[14/n][14%n]);
    scanf("%d",&d[15/n][15%n]);
    scanf("%d",&d[16/n][16%n]);
    scanf("%d",&d[17/n][17%n]);
    scanf("%d",&d[18/n][18%n]);
    scanf("%d",&d[19/n][19%n]);
    scanf("%d",&d[20/n][20%n]);
    scanf("%d",&d[21/n][21%n]);
    scanf("%d",&d[22/n][22%n]);
    scanf("%d",&d[23/n][23%n]);
    scanf("%d",&d[24/n][24%n]);
    scanf("%d",&d[25/n][25%n]);
    scanf("%d",&d[26/n][26%n]);
    scanf("%d",&d[27/n][27%n]);
    scanf("%d",&d[28/n][28%n]);
    scanf("%d",&d[29/n][29%n]);
    scanf("%d",&d[30/n][30%n]);
    scanf("%d",&d[31/n][31%n]);
    scanf("%d",&d[32/n][32%n]);
    scanf("%d",&d[33/n][33%n]);
    scanf("%d",&d[34/n][34%n]);
    scanf("%d",&d[35/n][35%n]);
    scanf("%d",&d[36/n][36%n]);
    scanf("%d",&d[37/n][37%n]);
    scanf("%d",&d[38/n][38%n]);
    scanf("%d",&d[39/n][39%n]);
    scanf("%d",&d[40/n][40%n]);
    scanf("%d",&d[41/n][41%n]);
    scanf("%d",&d[42/n][42%n]);
    scanf("%d",&d[43/n][43%n]);
    scanf("%d",&d[44/n][44%n]);
    scanf("%d",&d[45/n][45%n]);
    scanf("%d",&d[46/n][46%n]);
    scanf("%d",&d[47/n][47%n]);
    scanf("%d",&d[48/n][48%n]);
    scanf("%d",&d[49/n][49%n]);
    scanf("%d",&d[50/n][50%n]);
    scanf("%d",&d[51/n][51%n]);
    scanf("%d",&d[52/n][52%n]);
    scanf("%d",&d[53/n][53%n]);
    scanf("%d",&d[54/n][54%n]);
    scanf("%d",&d[55/n][55%n]);
    scanf("%d",&d[56/n][56%n]);
    scanf("%d",&d[57/n][57%n]);
    scanf("%d",&d[58/n][58%n]);
    scanf("%d",&d[59/n][59%n]);
    scanf("%d",&d[60/n][60%n]);
    scanf("%d",&d[61/n][61%n]);
    scanf("%d",&d[62/n][62%n]);
    scanf("%d",&d[63/n][63%n]);
    scanf("%d",&d[64/n][64%n]);
    scanf("%d",&d[65/n][65%n]);
    scanf("%d",&d[66/n][66%n]);
    scanf("%d",&d[67/n][67%n]);
    scanf("%d",&d[68/n][68%n]);
    scanf("%d",&d[69/n][69%n]);
    scanf("%d",&d[70/n][70%n]);
    scanf("%d",&d[71/n][71%n]);
    scanf("%d",&d[72/n][72%n]);
    scanf("%d",&d[73/n][73%n]);
    scanf("%d",&d[74/n][74%n]);
    scanf("%d",&d[75/n][75%n]);
    scanf("%d",&d[76/n][76%n]);
    scanf("%d",&d[77/n][77%n]);
    scanf("%d",&d[78/n][78%n]);
    scanf("%d",&d[79/n][79%n]);
    scanf("%d",&d[80/n][80%n]);
    scanf("%d",&d[81/n][81%n]);
    scanf("%d",&d[82/n][82%n]);
    scanf("%d",&d[83/n][83%n]);
    scanf("%d",&d[84/n][84%n]);
    scanf("%d",&d[85/n][85%n]);
    scanf("%d",&d[86/n][86%n]);
    scanf("%d",&d[87/n][87%n]);
    scanf("%d",&d[88/n][88%n]);
    scanf("%d",&d[89/n][89%n]);
    scanf("%d",&d[90/n][90%n]);
    scanf("%d",&d[91/n][91%n]);
    scanf("%d",&d[92/n][92%n]);
    scanf("%d",&d[93/n][93%n]);
    scanf("%d",&d[94/n][94%n]);
    scanf("%d",&d[95/n][95%n]);
    scanf("%d",&d[96/n][96%n]);
    scanf("%d",&d[97/n][97%n]);
    scanf("%d",&d[98/n][98%n]);
    scanf("%d",&d[99/n][99%n]);
    ans=0;
    d[0][0]=min(d[0][0],d[0][0]+d[0][0]);
    d[0][1]=min(d[0][1],d[0][0]+d[0][1]);
    d[0][2]=min(d[0][2],d[0][0]+d[0][2]);
    d[0][3]=min(d[0][3],d[0][0]+d[0][3]);
    d[0][4]=min(d[0][4],d[0][0]+d[0][4]);
    d[0][5]=min(d[0][5],d[0][0]+d[0][5]);
    d[0][6]=min(d[0][6],d[0][0]+d[0][6]);
    d[0][7]=min(d[0][7],d[0][0]+d[0][7]);
    d[0][8]=min(d[0][8],d[0][0]+d[0][8]);
    d[0][9]=min(d[0][9],d[0][0]+d[0][9]);
    d[1][0]=min(d[1][0],d[1][0]+d[0][0]);
    d[1][1]=min(d[1][1],d[1][0]+d[0][1]);
    d[1][2]=min(d[1][2],d[1][0]+d[0][2]);
    d[1][3]=min(d[1][3],d[1][0]+d[0][3]);
    d[1][4]=min(d[1][4],d[1][0]+d[0][4]);
    d[1][5]=min(d[1][5],d[1][0]+d[0][5]);
    d[1][6]=min(d[1][6],d[1][0]+d[0][6]);
    d[1][7]=min(d[1][7],d[1][0]+d[0][7]);
    d[1][8]=min(d[1][8],d[1][0]+d[0][8]);
    d[1][9]=min(d[1][9],d[1][0]+d[0][9]);
    d[2][0]=min(d[2][0],d[2][0]+d[0][0]);
    d[2][1]=min(d[2][1],d[2][0]+d[0][1]);
    d[2][2]=min(d[2][2],d[2][0]+d[0][2]);
    d[2][3]=min(d[2][3],d[2][0]+d[0][3]);
    d[2][4]=min(d[2][4],d[2][0]+d[0][4]);
    d[2][5]=min(d[2][5],d[2][0]+d[0][5]);
    d[2][6]=min(d[2][6],d[2][0]+d[0][6]);
    d[2][7]=min(d[2][7],d[2][0]+d[0][7]);
    d[2][8]=min(d[2][8],d[2][0]+d[0][8]);
    d[2][9]=min(d[2][9],d[2][0]+d[0][9]);
    d[3][0]=min(d[3][0],d[3][0]+d[0][0]);
    d[3][1]=min(d[3][1],d[3][0]+d[0][1]);
    d[3][2]=min(d[3][2],d[3][0]+d[0][2]);
    d[3][3]=min(d[3][3],d[3][0]+d[0][3]);
    d[3][4]=min(d[3][4],d[3][0]+d[0][4]);
    d[3][5]=min(d[3][5],d[3][0]+d[0][5]);
    d[3][6]=min(d[3][6],d[3][0]+d[0][6]);
    d[3][7]=min(d[3][7],d[3][0]+d[0][7]);
    d[3][8]=min(d[3][8],d[3][0]+d[0][8]);
    d[3][9]=min(d[3][9],d[3][0]+d[0][9]);
    d[4][0]=min(d[4][0],d[4][0]+d[0][0]);
    d[4][1]=min(d[4][1],d[4][0]+d[0][1]);
    d[4][2]=min(d[4][2],d[4][0]+d[0][2]);
    d[4][3]=min(d[4][3],d[4][0]+d[0][3]);
    d[4][4]=min(d[4][4],d[4][0]+d[0][4]);
    d[4][5]=min(d[4][5],d[4][0]+d[0][5]);
    d[4][6]=min(d[4][6],d[4][0]+d[0][6]);
    d[4][7]=min(d[4][7],d[4][0]+d[0][7]);
    d[4][8]=min(d[4][8],d[4][0]+d[0][8]);
    d[4][9]=min(d[4][9],d[4][0]+d[0][9]);
    d[5][0]=min(d[5][0],d[5][0]+d[0][0]);
    d[5][1]=min(d[5][1],d[5][0]+d[0][1]);
    d[5][2]=min(d[5][2],d[5][0]+d[0][2]);
    d[5][3]=min(d[5][3],d[5][0]+d[0][3]);
    d[5][4]=min(d[5][4],d[5][0]+d[0][4]);
    d[5][5]=min(d[5][5],d[5][

以上是关于codeforces 656 E Out of Controls Floyd的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #656

Codeforces Round #656 (Div. 3)

C F出现out of memory怎么办

Codeforces Round #656 (Div. 3)

codeforces 616E. Sum of Remainders 数学

Codeforces Round #656 (Div. 3) E. Directing Edges