比赛 |
20241127 |
评测结果 |
AAAAAAAAAA |
题目名称 |
魔法药水 |
最终得分 |
100 |
用户昵称 |
wdsjl |
运行时间 |
0.182 s |
代码语言 |
C++ |
内存使用 |
4.83 MiB |
提交时间 |
2024-11-27 11:11:45 |
显示代码纯文本
#include<bits/stdc++.h>
#define For(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
int minn[1010],ans[1010],d[1010][1010],b[1010];
int main(){
freopen("msyrup.in","r",stdin);
freopen("msyrup.out","w",stdout);
int n;
scanf("%d",&n);
For(i,1,n){
scanf("%d",&minn[i]);
ans[i]=1;
}
int x,y,z;
while(cin>>x>>y>>z){
d[x+1][y+1]=z+1;
d[y+1][x+1]=z+1;
}
For(i,1,n){
int now=0x3f3f3f3f,bj;
For(j,1,n){
if(!b[j]&&minn[j]<now){
bj=j;
now=minn[j];
}
}
b[bj]=1;
For(j,1,n){
if(b[j]&&d[bj][j]){
if(minn[bj]+minn[j]==minn[d[bj][j]])ans[d[bj][j]]+=ans[bj]*ans[j];
if(minn[bj]+minn[j]<minn[d[bj][j]]){
minn[d[bj][j]]=minn[bj]+minn[j];
ans[d[bj][j]]=ans[bj]*ans[j];
}
}
}
}
printf("%d %d",minn[1],ans[1]);
return 0;
}