HDU 2647Reward(拓扑图)
摘要:题意:过年发奖金,起始奖金为888.越后者比前者多1元。问一共发了多少奖金。注意:数据中2 1 表示有两个员工,一组数据。接下来一组数据1 2 表示先给2发奖金,再给1发奖金。也就是1的奖金为889,2的奖金为888.连接:http://acm.hdu.edu.cn/showproblem.php?pid=2647View Code #include <iostream>using namespace std;#include <vector>const int MAX=10000+10;vector<int >map[MAX];int used[MAX];
阅读全文
HDU 3342 Legal or Not(深搜+拓扑)
摘要:解题思路:没有环的拓扑图、连接:http://acm.hdu.edu.cn/showproblem.php?pid=3342View Code #include <iostream>using namespace std;const int MAX=100+10;int c[MAX];int topo[MAX][MAX];int map[MAX][MAX];int m;int n;int t;bool dfs(int k){ c[k]=-1; for(int i=0;i<n;i++) { if(map[k][i]) { if(...
阅读全文
hdu 1285 确定名次排名(拓扑排序)
摘要:题意:确定名次排名,符合条件的排名可能不是唯一的,此时要求输出时编号小的队伍在前;输入数据保证是正确的,即输入数据确保一定能有一个符合要求的排。注意事项:判重连接:http://acm.hdu.edu.cn/showproblem.php?pid=1285View Code #include <iostream>using namespace std;const int MAX=500+10;int map[MAX][MAX];int indegree[MAX];int main(){ int n; int m; while(~scanf("%d%d",&
阅读全文