简单的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. App推广干货,排名数据分析优化效果

    出处: App盈利交流论坛        2015年3月份,在百度上了一款赛车类游戏(不说什么名字了怕被打包),后台起名叫002,刚开始上的时候一天只有几元钱,但是游戏还是倾注了不少心血的,觉得不甘心 ...

  2. 检测SqlServer服务器CPU是否瓶颈

    初次写博文,分享个人心得,欢迎大虾小虾来拍砖. 系统自带的性能监视器 在开始命令框中输入perfmon按enter键即可打开性能监视器 可以通过监视 % Processor Time 的值察看cpu是 ...

  3. Java 源码学习线路————_先JDK工具包集合_再core包,也就是String、StringBuffer等_Java IO类库

    http://www.iteye.com/topic/1113732 原则网址 Java源码初接触 如果你进行过一年左右的开发,喜欢用eclipse的debug功能.好了,你现在就有阅读源码的技术基础 ...

  4. 第二篇、微信程序尺寸rpx

    微信小程序尺寸单位rpx以及样式相关介绍rpx单位是微信小程序中css的尺寸单位,rpx可以根据屏幕宽度进行自适应.规定屏幕宽为750rpx.如在 iPhone6 上,屏幕宽度为375px,共有750 ...

  5. Cocos移植到Android-使用Eclipse交叉编译打包

    如果对命令行望而生畏,我们可以借助于安装有ADT插件的Eclipse工具实现交叉编译.使用Eclipse进行交叉编译,首先需要将要编译的工程导入到Eclipse的Workspace中,Workspac ...

  6. HTML+CSS学习笔记(2) - 认识标签(1)

    HTML+CSS学习笔记(2) - 认识标签(1) 1.语义化,让你的网页更好的被搜索引擎理解 标签的用途: 我们学习网页制作时,常常会听到一个词,语义化.那么什么叫做语义化呢,说的通俗点就是:明白每 ...

  7. UIViewSubviews多个views之间的关系

    #import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...

  8. (POJ 3694) Network 求桥个数

    题目链接:http://poj.org/problem?id=3694Description A network administrator manages a large network. The ...

  9. 输入与enter

    #include<iostream> using namespace std; int main() { char a,b,c; while(scanf("%c%c%c" ...

  10. RHEL6.3 ftp服务器参数的戏说——不看白不看,看了不白看

    大家都知道ftp服务器的应用何止广,简直就是无处不在,配置简单的ftp服务谁都会,无外乎就是刚安装好ftp服务,一启动就ok了:或是达到简单的上传下载修改下/var/ftp/pub的权限,配合配置文件 ...