题意:

略。

思路:

n就10而已,没有环,搜一下就好了。。

#include <bits/stdc++.h>
using namespace std; typedef long long LL; const int mod=1e9+7;
const int N=10+10;
const int INF=0x3f3f3f3f; int ma[N][N];
bool flag[N];
bool vis[N];
int ans;
int n; void init()
{
memset(ma,INF,sizeof(ma));
memset(flag,0,sizeof(flag));
memset(vis,0,sizeof(vis));
} void dfs(int x,int sum)
{
if(sum>=ans)
return;
if(flag[x]==1)
{
ans=min(ans,sum);
return;
}
for(int i=0;i<n;i++)
{
if(i!=x&&!vis[i]&&ma[x][i]!=INF)
{
vis[i]=1;
dfs(i,sum+ma[x][i]);
vis[i]=0;
}
}
} int main()
{
while(~scanf("%d",&n))
{
init();
int num;
int k,x,y;
for(int i=0;i<n;i++)
{
scanf("%d%d",&num,&k);
if(k==1)
flag[i]=1;
for(int j=0;j<num;j++)
{
scanf("%d%d",&x,&y);
ma[i][x]=ma[x][i]=min(ma[i][x],y);
}
}
if(flag[0])
{
puts("0");
continue;
}
ans=INF;
vis[0]=1;
dfs(0,0);
printf("%d\n",ans);
}
return 0;
}

最新文章

  1. Windows7安装 .net framework 4.0
  2. Python3 的json 和 PHP的json
  3. NYOJ 485
  4. listview选中没有效果
  5. CentOS 配置solr中文分词器
  6. MyISAM与InnoDB的索引实现
  7. 使用SSMS 2014将本地数据库迁移到Azure SQL Database
  8. static作用——The static effect
  9. Laravel Eloquent ORM
  10. Remove Duplicate Letters
  11. 设置TextView水平居中显示
  12. ASP.NET CORE 1.0 初次接触
  13. mac中使用终端生成RSA私钥和公钥文件
  14. The Speed 歌词
  15. win10更新系统后,无法远程访问的bug
  16. Mybatis 使用了哪些设计模式?
  17. 100-days: eighteen
  18. wqCms6.0在IIS6的Getshell
  19. Qt简单项目--加法计算器(详细代码注释)
  20. 【慕课网实战】Spark Streaming实时流处理项目实战笔记五之铭文升级版

热门文章

  1. SpringCloud中Redis的使用
  2. scss - 语法
  3. 浏览器g.xxx333xxx.com 跳转2345问题解决方法
  4. HTML5已定稿:将彻底颠覆原生应用
  5. HDU 2049 不容易系列之(4)——考新郎 (递推,含Cmn公式)
  6. vue 安装与起步
  7. HTML页面中点击按钮关闭页面几种方式与取消
  8. 对FreeMarker技术的思考
  9. MTK平台下Battery驱动分析
  10. 20170224 SE11删除数据