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.

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 the maximum length of the shortest path between any pair of vertices in the graph.

NoteYou're running short of keywords, so you can't use some of them:definedoforforeachwhilerepeatuntilifthenelseelifelsifelseifcaseswitch

#include<stdio.h>
int n, arr[20][20], ma=-1;
int scan(int x)
{
    scanf("%d", &arr[x/n][x%n]);
    return x=x<n*n-1?scan(x+1):0;
}
int solve(int x)
{
    int i, j, k;
    k=(x/n)/n;//00001111
    i=(x/n)%n;//00110011
    j=(x%n);//01010101
    arr[i][j]=arr[i][j]>arr[i][k]+arr[k][j]?arr[i][k]+arr[k][j]:arr[i][j];
    return x=x<n*n*n-1?solve(x+1):0;
}
int get_max(int x)
{
    int i, j;
    i=x/n;
    j=x%n;
    ma=arr[i][j]>ma?arr[i][j]:ma;
    return x<n*n-1?get_max(x+1):0;
}
int main()
{
    int i, j;
    scanf("%d", &n);
    scan(0);
    solve(0);
    get_max(0);
    printf("%d", ma);
}

#include <stdio.h>

const unsigned char N = (unsigned char) 10;

unsigned char n;
int x;
int mat[10][10];

 unsigned char smin(const unsigned char a, const unsigned char b) { return a < b ? a : b; }
 unsigned char smax(const unsigned char a, const unsigned char b) { return a > b ? a : b; }

 unsigned char FOR3(const unsigned char k, const unsigned char i, const unsigned char j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

 unsigned char FOR2(const unsigned char i, const unsigned char j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

 unsigned char FOR1(const unsigned char i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

 unsigned char FOR_INPUT2(const unsigned char i, const unsigned char j) {
    scanf("%d", &x);
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 unsigned char FOR_INPUT1(const unsigned char i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 unsigned char BILLY2(const unsigned char i, const unsigned char j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 unsigned char BILLY1(const unsigned char i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%d", &x); n = x;
    FOR_INPUT1(0);
    FOR1(0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>

const short N = (short) 10;

short n;
int x;
short mat[10][10];

 short smin(const short a, const short b) { return a < b ? a : b; }
 short smax(const short a, const short b) { return a > b ? a : b; }

 short FOR3(const short k, const short i, const short j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

 short FOR2(const short i, const short j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

 short FOR1(const short i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

 short FOR_INPUT2(const short i, const short j) {
    scanf("%d", &x);
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 short FOR_INPUT1(const short i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 short BILLY2(const short i, const short j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 short BILLY1(const short i) {
    short ans = BILLY2(i, 0);
    short other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%d", &x); n = x;
    FOR_INPUT1(0);
    FOR1(0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>

const short N = (short) 10;

short n;
short mat[10][10];

 short smin(const short a, const short b) { return a < b ? a : b; }
 short smax(const short a, const short b) { return a > b ? a : b; }

 short FOR3(const short k, const short i, const short j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

 short FOR2(const short i, const short j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

 short FOR1(const short i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

 short FOR_INPUT2(const short i, const short j) {
    scanf("%hd", &mat[i][j]);
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 short FOR_INPUT1(const short i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 short BILLY2(const short i, const short j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 short BILLY1(const short i) {
    short ans = BILLY2(i, 0);
    short other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%hd", &n);
    FOR_INPUT1(0);
    FOR1(0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>

const unsigned char N = (unsigned char) 10;

unsigned char n;
int x;
unsigned char mat[10][10];

 unsigned char smin(const unsigned char a, const unsigned char b) { return a < b ? a : b; }
 unsigned char smax(const unsigned char a, const unsigned char b) { return a > b ? a : b; }

 unsigned char FOR3(const unsigned char k, const unsigned char i, const unsigned char j) {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR3(k, i, j + 1) : 0;
}

 unsigned char FOR2(const unsigned char i, const unsigned char j) {
    FOR3(i, j, 0);
    return j + 1 < n ? FOR2(i, j + 1) : 0;
}

 unsigned char FOR1(const unsigned char i) {
    FOR2(i, 0);
    return i + 1 < n ? FOR1(i + 1) : 0;
}

 unsigned char FOR_INPUT2(const unsigned char i, const unsigned char j) {
    scanf("%d", &x);
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 unsigned char FOR_INPUT1(const unsigned char i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 unsigned char BILLY2(const unsigned char i, const unsigned char j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 unsigned char BILLY1(const unsigned char i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%d", &x); n = x;
    FOR_INPUT1(0);
    FOR1(0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>

const unsigned char N = (unsigned char) 10;

unsigned char n;
int x;
unsigned char mat[10][10];

 unsigned char smin(const unsigned char a, const unsigned char b) { return a < b ? a : b; }
 unsigned char smax(const unsigned char a, const unsigned char b) { return a > b ? a : b; }

unsigned char FOR4(const unsigned char k, const unsigned char i, const unsigned char j)  {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR4(k, i, j + 1) :
                i + 1 < n ? FOR4(k, i + 1, 0) :
                k + 1 < n ? FOR4(k + 1, 0, 0) : 0;
}

 unsigned char FOR_INPUT2(const unsigned char i, const unsigned char j) {
    scanf("%d", &x);
    mat[i][j] = x;
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 unsigned char FOR_INPUT1(const unsigned char i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 unsigned char BILLY2(const unsigned char i, const unsigned char j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 unsigned char BILLY1(const unsigned char i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%d", &x); n = x;
    FOR_INPUT1(0);
    // FOR1(0);
    FOR4(0, 0, 0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}

#include <stdio.h>

const int oo = (int)1e9;
int n;
int d[10][10];
int ans = 0;

int poop1(int i, int j)
{
	return i == n ? 0 : (
		j == n ? poop1(i + 1, 0) : (
			scanf("%d", &d[i][j]) + poop1(i, j + 1)
		)
	);
}

int poop2(int i, int j, int k)
{
	return k == n ? 0 : (
		i == n ? poop2(0, 0, k + 1) : (
			j == n ? poop2(i + 1, 0, k) : (
				(d[i][j] = d[i][j] > d[i][k] + d[k][j] ? d[i][k] + d[k][j] : d[i][j])
				+ poop2(i, j + 1, k)
			)
		)
	);
}

int poop3(int i, int j)
{
	return i == n ? 0 :  (
		j == n ? poop3(i + 1, 0) : (
			(ans = ans < d[i][j] ? d[i][j] : ans) + poop3(i, j + 1)
		)
	);
}

int main()
{
	scanf("%d", &n);

	poop1(0, 0);
	poop2(0, 0, 0);
	poop3(0, 0);

	printf("%d\n", ans);

	return 0;
}

#include <stdio.h>

const unsigned char N = (unsigned char) 10;

unsigned char n;
unsigned char mat[10][10];

 unsigned char smin(const unsigned char a, const unsigned char b) { return a < b ? a : b; }
 unsigned char smax(const unsigned char a, const unsigned char b) { return a > b ? a : b; }

unsigned char FOR4(const unsigned char k, const unsigned char i, const unsigned char j)  {
    mat[i][j] = smin(mat[i][j], mat[i][k] + mat[k][j]);
    return j + 1 < n ? FOR4(k, i, j + 1) :
                i + 1 < n ? FOR4(k, i + 1, 0) :
                k + 1 < n ? FOR4(k + 1, 0, 0) : 0;
}

 unsigned char FOR_INPUT2(const unsigned char i, const unsigned char j) {
    scanf("%d", &mat[i][j]);
    return j + 1 < n ? FOR_INPUT2(i, j + 1) : 0;
}

 unsigned char FOR_INPUT1(const unsigned char i) {
    FOR_INPUT2(i, 0);
    return i + 1 < n ? FOR_INPUT1(i + 1) : 0;
}

 unsigned char BILLY2(const unsigned char i, const unsigned char j) {
    return smax(mat[i][j], j + 1 < n ? BILLY2(i, j + 1) : 0);
}

 unsigned char BILLY1(const unsigned char i) {
    unsigned char ans = BILLY2(i, 0);
    unsigned char other = i + 1 < n ? BILLY1(i + 1) : 0;
    return smax(ans, other);
}

void solve() {
    scanf("%d", &n);
    FOR_INPUT1(0);
    // FOR1(0);
    FOR4(0, 0, 0);
    printf("%d\n", BILLY1(0));
}

int main() {
    solve();
    return 0;
}