hdu4324
来源:互联网 发布:手机网络赚钱资源 编辑:程序博客网 时间:2024/05/01 13:00
/*
分析:
拓扑排序。
深搜啊什么的都行。
2012-12-13
*/
分析:
拓扑排序。
深搜啊什么的都行。
2012-12-13
*/
#include"stdio.h"#include"string.h"#include"stdlib.h"#include"queue"#define N 2011using namespace std;int n;char map[N][N];int indegree[N];struct Eage{int from,to,next;}eage[N*N/2];int tot,head[N];void add(int a,int b){eage[tot].from=a;eage[tot].to=b;eage[tot].next=head[a];head[a]=tot++;}void get_map(){int i,l;tot=0;memset(head,-1,sizeof(head));memset(indegree,0,sizeof(indegree));for(i=0;i<n;i++){scanf("%s",&map[i]);for(l=0;map[i][l];l++)if(map[i][l]=='1'){add(i,l);indegree[l]++;}}}int topsort(){int i,j;int k=0;int flag;while(k<n){flag=0;for(i=0;i<n;i++){if(indegree[i])continue;k++;flag=1;indegree[i]--;for(j=head[i];j!=-1;j=eage[j].next)indegree[eage[j].to]--;}if(!flag)return 1;}return 0;}int main(){int T,Case;int ans;scanf("%d",&T);for(Case=1;Case<=T;Case++){scanf("%d",&n);get_map();ans=topsort();if(ans)printf("Case #%d: Yes\n",Case);elseprintf("Case #%d: No\n",Case);}return 0;}
- hdu4324
- hdu4324
- hdu4324 拓扑排序
- hdu4324(拓扑排序)
- hdu4324 拓扑排序
- HDU4324(拓扑排序)
- hdu4324(拓扑排序)
- HDU4324-Triangle LOVE
- Triangle LOVE (hdu4324)
- HDU4324 Triangle LOVE 【拓扑排序】
- hdu4324——Triangle LOVE
- HDU4324 Triangle LOVE【拓扑排序】
- HDU4324 Triangle Love【拓扑排序】
- 拓扑排序 hdu4324 Triangle LOVE
- hdu4324 Triangle LOVE(拓扑排序)
- HDU4324(强连通的Tarjan算法)
- hdu4324 Triangle LOVE (拓扑排序)
- hdu4324 Triangle LOVE (拓扑判断环)
- Origin_8.0_crack(origin8.0序列号(origin8.0破解补丁))
- 配置文件当中怎样修改request validation mode
- Linux修改SSH端口和禁止Root远程登陆
- 在WYSIWYG模块中为Drupal 7配置CKEditor 4
- Python Windows Service的方式运行
- hdu4324
- 算两个日期相差天数之使用Calendar类型注意事项
- magento 开发者笔记1
- js键盘键值
- cygwin编译ffmpeg
- c语言大小端转化
- 一些想法吧
- android 获得手机号相关
- MongoDB Note