简单的dfs  但繁琐的可以了 0.0

#include<cstdio>
#include<cstring>
#include<algorithm>
using std::sort;
int n,m,cnt=0;
struct team
{
char s[50];
int low,up,d,f;
};
team a[30];
struct match
{
int x,y,re;
bool operator < (const match &p) const
{
return re < p.re;
}
};
match b[2000];
int find(char *s)
{
for(int i = 0; i < n; i++)
if(strcmp(a[i].s, s) == 0)
return i;
return -1;
} void cc(int w)
{
for(int i = 0; i < n; i++)
a[i].f = a[i].d;
for(int i = 0; i < w; i++)
if(b[i].re == 1)
{
a[b[i].x].f += 1;
a[b[i].y].f += 1;
}
else if(b[i].re == 2)
a[b[i].x].f += 3;
else
a[b[i].y].f += 3;
for(int i = 0; i < n; i++)
{
int rank=1;
for(int j = 0; j < n; j++)
{
if(j != i && a[j].f > a[i].f)
rank++;
}
if(rank > a[i].low)
a[i].low = rank;
if(rank < a[i].up)
a[i].up = rank;
}
}
void dfs(int cur,int w)
{
if(cur == w)
cc(w);
else
{
for(int i = 1; i <= 3; i++)
{
b[cur].re = i;
dfs(cur+1, w);
}
b[cur].re = 0;
}
}
void show(int a)
{
if(a == 1)
printf("1st ");
else if(a == 2)
printf("2nd ");
else if(a == 3)
printf("3rd ");
else
printf("%dth ", a);
} void show(team a)
{
printf("Team %s can finish as high as ",a.s);
show(a.up);
printf("place and as low as ");
show(a.low);
printf("place.\n");
}
int main()
{
while(scanf("%d%d",&n,&m) && m+n)
{
if(cnt++)
printf("\n");
int p,q;
char u[100],v[100];
for(int i = 0; i < n; i++)
{
scanf("%s",a[i].s);
a[i].d = a[i].low = 0, a[i].up = 50;
}
for(int i = 0; i < m; i++)
{
scanf("%s vs %s%d%d",u,v,&p,&q);
v[strlen(v)-1] = '\0';
b[i].x = find(u);
b[i].y = find(v);
int &re = b[i].re;
if(p==-1 && q==-1)
re = 0;
else if(p == q)
re = 1;
else if(p > q)
re = 2;
else
re = 3;
}
sort(b, b+m);
int j = 0;
for(j = 0; j < m; j++)
if(b[j].re != 0)
break;
for(int i = j; i < m; i++)
if(b[i].re == 1)
{
a[b[i].x].d += 1;
a[b[i].y].d += 1;
}
else if(b[i].re == 2)
a[b[i].x].d += 3;
else
a[b[i].y].d += 3;
dfs(0, j);
for(int i = 0; i < n; i++)
show(a[i]);
}
return 0;
}

hdu 3778的更多相关文章

  1. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  2. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  4. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  5. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  6. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  7. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

  8. hdu 4481 Time travel(高斯求期望)(转)

    (转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...

  9. HDU 3791二叉搜索树解题(解题报告)

    1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...

随机推荐

  1. SVN对unity3d项目版本进行管理的不方便问题,研究ing

    unity3d项目版本控制遇到些问题,找了以下资料做参考,现在mark一下,以后慢慢解决,之后总结. Unity开启meta. meta:版本控制文件,在新加入项时,Unity3D会产生一个同名的.m ...

  2. AjaxFileUpload 在C#中应用

    一.前台页面 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head ru ...

  3. 关于web上的图片格式问题,新的彩蛋

    我们耳熟能详的几种格式无外乎 png-8,png-24,jpeg,gif,svg. 但是上面的那些都不是能够另人惊喜的答案.关于新技术的是Webp,Apng.(是否有关注新技术,新鲜事物) 1)Web ...

  4. springMVC学习篇 - 搭建环境及关键点

    springMVC是spring家族中一个重要的组件,和struts一样作为一套前台框架被广泛的应用于各种项目. 之前在很多项目组都用到springMVC,只感觉很强大,但是对这套框架的知识了解比较少 ...

  5. CentOS6.6图文详细安装教程(有些设置大部分教程没出现过,附带网络设置等)

    作者:Sungeek 出处:http://www.cnblogs.com/Sungeek/ 欢迎转载,也请保留这段声明.谢谢! Centos6.6 下载地址:thunder://QUFodHRwOi8 ...

  6. extends 与 implements 的区别

    extends与implements是Java继承中使用的两个关键字,但extends与implements使用的情景不同: 1.接口继承接口,使用extends 2.类继承类时,用extends 3 ...

  7. C++与Lua交互(二)

    上一篇我们搭建好了整个的项目环境,现在,我们一起探索一下如何将lua寄宿到C++中. 宿主的实现 我们在LuaWithCPPTest项目下,查看Source.cpp代码如下: #include < ...

  8. 用一天的时间学习Java EE中的SSH框架

    首先说明一下,本人目前主要从事.NET领域的工作,但对于C++.Java.OC等语言也略知一二,周末闲来无事,特花费一天的时间学习了一下Java中的SSH框架,希望把学习过程中的心得体会与园友们进行分 ...

  9. jquery实现视觉滚动--fullpage

    用fullpage.js实现视觉滚动效果 1.Html页面 <!DOCTYPE html> <html> <head> <meta charset=" ...

  10. 简单使用packetbeat

    简单使用packetbeat 标签:packetbeat elasticsearch 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在前面两篇文章中记录了使用logstash来收集mysql的慢 ...