```c
const int inf=e[1][1];cin>>q;
for(int i=1;i<=q;i++)
{
int x,y,t;
cin>>x>>y>>t;
while(ttt<n && a[ttt]<=t)
{
for(int j=0;j<n;j++)
for(int k=0;k<n;k++)
if(e[j][k]>e[j][ttt]+e[ttt][k] && e[j][ttt]<inf && e[ttt][k]<inf)
e[j][k]=e[j][ttt]+e[ttt][k];
ttt++;
}
if(a[x]>t || a[y]>t)cout<<-1<<endl;
else if(e[x][y]==inf)cout<<-1<<endl;
else cout<<e[x][y]<<endl;
}
```
by AC_NOIP_AK_IOI @ 2023-03-26 16:49:50
```c
if(e[j][k]>e[j][ttt]+e[ttt][k] && e[j][ttt]<inf && e[ttt][k]<inf)
e[j][k]=e[j][ttt]+e[ttt][k];
```
by AC_NOIP_AK_IOI @ 2023-03-26 16:59:10
这是我的。
by AC_NOIP_AK_IOI @ 2023-03-26 16:59:40
```c
if(a[i]<=t && a[j]<=t){
f[i][j]=min(f[i][j],f[i][last]+f[last][j]);
}
```
这是你的。
by AC_NOIP_AK_IOI @ 2023-03-26 17:00:04