2011年4月21日

zoj1082Stockbroker Grapevine

摘要: #include<iostream>#include<queue>#include<algorithm>#include<cstring>using namespace std;int n,g[101][101],d[101];const int INF=10000000;int broken;int spfa(int x){ queue <int > q; q.push(x); bool inq[101]; memset(inq,0,sizeof(inq)); for(int i=1;i<=n;i++)d[i]=(i==x?0 阅读全文
posted @ 2011-04-21 19:08 4.5.6 阅读(152) 评论(0) 推荐(0) 编辑
2011年4月19日

zju1085Alien Security

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=85zju Alien Security spfa#include<iostream>#include<algorithm>#include<string>#include<cstring>#include<queue>using namespace std;const int INF=1000000;int vis[101],g[101][101],d[101];int n,ET;//ET目标房间void spfa( 阅读全文
posted @ 2011-04-19 22:25 4.5.6 阅读(151) 评论(0) 推荐(0) 编辑
2011年4月18日

zoj1589Professor John

摘要: #include<string>#include<set>#include<iostream>#include<cstring>using namespace std;/*题意:根据已有的变量关系能否推出别的变量关系(条件中已给出的滤去,若推不出别的关系输出NONE)传递闭包*/int small[30][30],vis[30][30],hash[30][30];//vis[][]标记关系在输入中已给出,hash[][]表示关系已在DFS中得到 set <string> ans; void DFS(int x,int cet){ fo 阅读全文
posted @ 2011-04-18 23:14 4.5.6 阅读(177) 评论(0) 推荐(0) 编辑

zoj1068P,MTHBGWB

摘要: #include<iostream>#include<string>#include<cstring>#include<map>using namespace std;int key[100];string ans;map <char,int> m;map <char,string> c;map <string,char> d;void set(){ m['A']=2;m['B']=4,m['C']=4,m['D']=3,m['E' 阅读全文
posted @ 2011-04-18 22:02 4.5.6 阅读(212) 评论(0) 推荐(0) 编辑
2011年4月15日

zoj1119SPF

摘要: 割点算法example1 21 31 42 52 63 73 84 94 80下面是算法运行过程 from 1 enter to the adj ares 2from 2 enter to the adj ares 5end 5return 2 is a cut node ,find subnet 1from 2 enter to the adj ares 6end 6return 2 is a cut node ,find subnet 2end 2from 1 enter to the adj ares 3from 3 enter to the adj ares 7end 7return 阅读全文
posted @ 2011-04-15 17:02 4.5.6 阅读(175) 评论(0) 推荐(0) 编辑

zoj1060Sorting It All Out

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=60拓扑排序0度>1多解0度==1正常0度==0矛盾#include<iostream>#include<stdio.h>#include<queue>#include<string>#include<algorithm>#include<cstring>using namespace std;int vis[30],d[30],adj[30][30];int m,n,flag,ok,pos;stri 阅读全文
posted @ 2011-04-15 08:40 4.5.6 阅读(197) 评论(0) 推荐(0) 编辑
2011年4月14日

zoj1311Network

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=311割点算法《算法与艺术信息学竞赛》P285建立在DFS的基础上#include<iostream>#include<cstring>#include<vector>#include<algorithm>#include<stdio.h>#include<string>#include<sstream>using namespace std;int n,m,k,ans,d[101],ances 阅读全文
posted @ 2011-04-14 09:05 4.5.6 阅读(181) 评论(0) 推荐(0) 编辑
2011年4月13日

zoj2050Flip Game

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1050位运算+BFS^运算表示 翻转#include<iostream>#include<string>#include<queue>#include<cstring>using namespace std;int vis[(1<<16)+1],dir[5][2]={1,0,-1,0,0,1,0,-1,0,0};int ANS;struct node{ int step,key;};node fir;string m 阅读全文
posted @ 2011-04-13 21:31 4.5.6 阅读(216) 评论(0) 推荐(0) 编辑
2011年4月12日

hdu 1072

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1072题目难点在于标记 状态vis[x][y][time] 表示在倒计时为time时走到了(x,y)处优先队列+BFS#include<iostream>#include<stdio.h>#include<queue>#include<cstring>using namespace std;int cas,n,m;int map[10][10],vis[10][10][7],dir[4][2]={1,0,-1,0,0,1,0,-1},ans;struct nod 阅读全文
posted @ 2011-04-12 23:47 4.5.6 阅读(790) 评论(0) 推荐(0) 编辑
2011年4月10日

zoj 2474Benny's Compiler

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1475水水的拓扑的一部分事先看别人的解题报告再做的,注意测试数据里有 a b,#include<iostream>#include<cstring>using namespace std;int n,m,f,tar,ans,ok;int g[105][105],vis[105];void topo(int x){ if(!ok)return; vis[x]=1; for(int i=1;i<=n;i++) { if(g[x][i]) { if(v 阅读全文
posted @ 2011-04-10 23:07 4.5.6 阅读(259) 评论(0) 推荐(0) 编辑