Schedule zoj 3348
2010-09-20 11:43
323 查看
Schedule
Time Limit: 1 Second Memory Limit: 32768 KB
DD enters the top-level pingpong match! As the game going on, he wonders if there is possibility for him to get the champion(excluding joint champions). Now provide you the results of previous matches, and the details of rest matches. You have to judge it.
Input
There are several test cases. You should process to the end of input.
For each test case. the first line contain two integers n (1 <= n <= 50) and m(0 <= m <= 1000), n indicates the number of players. m indicates the matches have ended.
Then for the following m lines, each line has the format: "Player1 Player2 Result". Player1 and Player2 are the names of the two players, and Result could only be "win" or "lose".
In the next line there is another integer p (0 <= p <= 5000), indicates the matches that will start later.
Then for the following p lines, each line has the format: "Player1 Player2", which means Player1 and Player2 will start a match.
We ensure there is a player named "DD". The length of each player name is no longer than 10.
Output
You should only output "Yes" or "No" for each case, which means if DD has the possibility to be the champion.
Sample Input
Sample Output
Time Limit: 1 Second Memory Limit: 32768 KB
DD enters the top-level pingpong match! As the game going on, he wonders if there is possibility for him to get the champion(excluding joint champions). Now provide you the results of previous matches, and the details of rest matches. You have to judge it.
Input
There are several test cases. You should process to the end of input.
For each test case. the first line contain two integers n (1 <= n <= 50) and m(0 <= m <= 1000), n indicates the number of players. m indicates the matches have ended.
Then for the following m lines, each line has the format: "Player1 Player2 Result". Player1 and Player2 are the names of the two players, and Result could only be "win" or "lose".
In the next line there is another integer p (0 <= p <= 5000), indicates the matches that will start later.
Then for the following p lines, each line has the format: "Player1 Player2", which means Player1 and Player2 will start a match.
We ensure there is a player named "DD". The length of each player name is no longer than 10.
Output
You should only output "Yes" or "No" for each case, which means if DD has the possibility to be the champion.
Sample Input
3 2 DD winsty win DD owen lose 2 winsty owen DD owen 3 3 DD winsty win DD owen lose winsty owen lose 2 owen winsty owen DD
Sample Output
Yes No
很经典的构图,最大流!
先统计每个人已经赢的次数和假设比赛他赢的次数,记c[i]
S连到每个赛手,流量为C[i]
……
int Getid(string name) { int i,j; for(i=1;i<=alr;i++) { if(name==person[i]) return i; } //cannot find such name person[++alr]=name; return alr; } void init() { memset(p, -1, sizeof(p)); memset(champ,0,sizeof(champ)); memset(c,0,sizeof(c)); ans = indexx = 0; int i,j,p1,p2,dd=0; string na1,na2,status; alr=0; for(i=0;i<temp;i++) { cin>>na1>>na2>>status; if(status[0]=='w') { if(na1=="DD") dd++; else { p1=Getid(na1); c[p1]++; ans++; } } else { if(na2=="DD") dd++; else { p2=Getid(na2); c[p2]++; ans++; } } } cin>>temp; for(i=0;i<temp;i++) { cin>>na1>>na2; //suppose first people win if(na1=="DD"||na2=="DD") {dd++;continue;} p1=Getid(na1); p2=Getid(na2); c[p1]++; champ[p1][p2]++; ans++; } for(i=1;i<=n;i++) { add(0,i,c[i]); add(i,n+1,dd-1); for(j=1;j<=n;j++) add(i,j,champ[i][j]); } }
相关文章推荐
- 【 zoj 3348 】Schedule 【网络流经典建图】
- zoj 3348 Schedule 【最大流经典建模】 【好题】
- ZOJ 3348 Schedule(map运用+网络流之最大流)(竞赛问题升级版)
- ZOJ 3430 Pizza schedule
- zoj 3348
- HDU Task Schedule && ZOJ Talented Chef
- zoj 3348
- zoj 3538 Arrange the Schedule
- ZOJ_Arrange the Schedule
- zoj 3538 Arrange the Schedule[矩阵]
- zoj 3348 网络流 汇总
- zoj 3538 Arrange the Schedule
- ZOJ 3348 网络流最大流 解题报告
- ZOJ 3538 Arrange the Schedule / 矩阵快速幂
- 【模拟退火】POJ 2420/ZOJ 1901 费马点
- 带花树(一般图最大匹配)详解 ZOJ 3316
- zoj 2100 水dfs
- ZOJ 3752 The Three Guys(暴力)
- zoj 2966
- Linux内核进程调度schedule深入理解