problem
solution
codes
//Floyd-wallshall模板
#include<iostream>
using namespace std;
int n, e[110][110];
int main(){
ios::sync_with_stdio(false);
cin>>n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
cin>>e[i][j];
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
if(e[i][k]+e[k][j]<e[i][j])
e[i][j] = e[i][k]+e[k][j];
int T; cin>>T;
while(T--){
int a, b;
cin>>a>>b;
cout<<e[a][b]<<"\n";
}
return 0;
}