比赛 |
4043级NOIP2022欢乐赛4th |
评测结果 |
AAAAA |
题目名称 |
希望小学 |
最终得分 |
100 |
用户昵称 |
op_组撒头屯 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-11-07 21:35:05 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=30+5;
const int M=100+5;
const int inf=0x3f3f3f3f;
int n,m;
int b[5],g[5];
int x[N],y[N];
int mp1[N][N],mp2[N][N];
int main(){
freopen ("hopeschool.in","r",stdin);
freopen ("hopeschool.out","w",stdout);
memset(mp1,0x3f,sizeof(mp1));
memset(mp2,0x3f,sizeof(mp2));
scanf("%d",&n);
for (int i=1;i<=3;i++)scanf("%d",&b[i]);
for (int i=1;i<=3;i++)scanf("%d",&g[i]);
for (int i=1;i<=n;i++)scanf("%d",&x[i]),mp1[i][i]=mp2[i][i]=0;
for (int i=1;i<=n;i++)scanf("%d",&y[i]);
scanf("%d",&m);
for (int i=1;i<=m;i++){
int x,y,s[5];scanf("%d%d",&x,&y);
for (int j=1;j<=3;j++)scanf("%d",&s[j]);
mp1[x][y]=s[1]*b[1]+s[2]*b[2]+s[3]*b[3];
mp2[x][y]=s[1]*g[1]+s[2]*g[2]+s[3]*g[3];
mp1[y][x]=s[1]*b[1]+s[3]*b[2]+s[2]*b[3];
mp2[y][x]=s[1]*g[1]+s[3]*g[2]+s[2]*g[3];
}
for (int k=1;k<=n;k++){
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
if (k!=i&&k!=j&&i!=j&&mp1[i][k]!=inf&&mp1[k][j]!=inf){
mp1[i][j]=min(mp1[i][j],mp1[i][k]+mp1[k][j]);
}
if (k!=i&&k!=j&&i!=j&&mp2[i][k]!=inf&&mp2[k][j]!=inf){
mp2[i][j]=min(mp2[i][j],mp2[i][k]+mp2[k][j]);
}
}
}
}
int mn=inf,mni=0;
for (int i=1;i<=n;i++){
int now=0;
for (int j=1;j<=n;j++)now+=x[j]*mp1[j][i]+y[j]*mp2[j][i];
if (now<mn){
mn=now;mni=i;
}
}
printf("%d\n",mni);
return 0;
}