博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
USACO Controlling Companies chapter 2.3 已跪
阅读量:4694 次
发布时间:2019-06-09

本文共 1473 字,大约阅读时间需要 4 分钟。

dfs搞了半天硬是没过,看了别人的题解我感觉却更加迷惑了..

1 /* 2  3 ID: hubiao cave 4  5 PROG: concom 6  7 LANG: C++ 8  9 */10 11 12 #include 
13 #include
14 #include
15 #include
16 using namespace std; 17 int have[101][101]; 18 int control[101][101]; 19 int main() { 20 ofstream fout ("concom.out"); 21 ifstream fin ("concom.in"); 22 int N,i,j,p,num; 23 fin>>N; 24 memset(control,0,sizeof(control)); 25 for(int a=0;a<101;a++) 26 control[a][a]=1; 27 for(int a=0;a
>i>>j>>p; 30 have[i][j]=p; 31 if(p>50) 32 control[i][j]=true; 33 } 34 bool judge=true; 35 while(judge) 36 { 37 judge=false; 38 for(int a=1;a<101;a++) 39 for(int b=1;b<101;b++) 40 { 41 if(!control[a][b])//在不知道a是否能控制b的情况下 42 { 43 num=0; 44 for(int c=1;c<101;c++)//累加通过a控制多个c从而使a拥有的b的股份达到50以上 45 if(b!=c&&control[a][c]) 46 num+=have[c][b]; 47 if(num>50) 48 { 49 control[a][b]=true; 50 judge=true; 51 } 52 } 53 } 54 } 55 for(int a=1;a<101;a++) 56 for(int b=1;b<101;b++) 57 { 58 if(control[a][b]&&a!=b) 59 fout<
<<" "<<

 

转载于:https://www.cnblogs.com/cavehubiao/p/3314511.html

你可能感兴趣的文章
python自动化七--操作mongodb,模块导入,接口开发,读取excel,修改excel
查看>>
iOS 开发笔记-UILable/UIFont/UIButton常见设置
查看>>
操作系统进程间通信简述
查看>>
2016-2017 National Taiwan University World Final Team Selection Contest
查看>>
2018 Wannafly summer camp Day3--Shopping
查看>>
(转)wireshark过滤语法总结
查看>>
阿里云大数据三次技术突围:Greenplum、Hadoop和“飞天”
查看>>
项目一~达人美食图册详情
查看>>
Border Collapse differences in FF and Webkit
查看>>
shell 中数组学习
查看>>
解决scrollView中嵌套编辑框导致不能上下滑动的问题
查看>>
<mvc:annotation-driven/>与<context:annotation-config/>的区别
查看>>
Dijkstra算法
查看>>
F01:金融学第一定律:时间的价值
查看>>
笔记--Day1--python基础1
查看>>
win8 中实现断点续传
查看>>
C语言条件编译(DEBUG思想)
查看>>
汇编语言实验三
查看>>
plsql+绿色版oracle连接远程数据库配置及提示缺少msvcr71.dll解决方法
查看>>
[py]python的继承体系
查看>>