| 比赛 |
期末考试3 |
评测结果 |
AAAAAAEEEEEEEEEEEEEE |
| 题目名称 |
hope I can jump |
最终得分 |
30 |
| 用户昵称 |
dream |
运行时间 |
4.342 s |
| 代码语言 |
C++ |
内存使用 |
12.11 MiB |
| 提交时间 |
2026-02-11 12:27:59 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;
int n,q;
ll g[N][N][N];
void work(){
for(int l=1;l<=n;l++){
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(k==l||i==l||j==l) continue;
g[i][j][l]=min(g[i][j][l],g[i][k][l]+g[k][j][l]);
}
}
}
}
}
int main(){
freopen("hopeicanjump.in","r",stdin);
freopen("hopeicanjump.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>q;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>g[i][j][0];
for(int k=1;k<=n;k++){
g[i][j][k]=g[i][j][0];
}
}
}
work();
while(q--){
int s,t,p;
cin>>s>>t>>p;
cout<<g[s][t][p]<<"\n";
}
return 0;
}