题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3757

题意:根据所给的台球规则,按照每次的结果计算最终两人的得分

单纯的模拟题,分支比较多写起来较繁琐

注意区分犯规与进球得分的规则:

只要有犯规行为,都要按照规则给对手加分。无论是否进球。

当进球时,如果有犯规行为,不仅分要加给对手,还要加上犯规惩罚

 #include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 10005
int v[];
int a,b;
bool flag;//碰谁了
bool flag1;//先碰的球ok
bool flag2;//有球进球
bool flag4;//没碰到球
bool flag3;//target
bool flag0;//白球进洞
int _min,_max;
int firsth;//最大的
int vis[maxn];
int low,high; int main()
{
int n,m,i;
flag=true;
while(~scanf("%d%d",&n,&m))
{
flag=true;
a=b=;
for(i=;i<=n;i++)
scanf("%d",&v[i]);
sort(v,v+n);
low=;//high=n;
_min=v[];//_max=v[n];
memset(vis,false,sizeof(vis));
while(m--)
{
int p,q;
scanf("%d",&p);
flag4=false;
if(p!=)
{
if(p==)
{
flag4=true;
}
else
{
flag1=false;
int x;
firsth=;
while(p--)
{
scanf("%d",&x);
if(x>firsth)
firsth=x;
}
}
}
else
{
scanf("%d",&p);
if(p!=_min)
flag1=false;
else
flag1=true;
firsth=p;
}
scanf("%d",&q);//进的球
if(q==)
flag2=false;
else
flag2=true;
int all=;
int y;
flag0=false;
flag3=false;
for(i=;i<q;i++)
{
scanf("%d",&y);
if(y==)
{
flag0=true;//白球进洞
}
if(y==_min)
{
flag3=true;//target
}
all+=y;
vis[y]=true;
}
if(flag4)//没碰到任何球
{
if(flag)
b+=_min;
else
a+=_min;
flag=!flag;
}
else//碰到球了
{
if(flag0)//白球进洞
{
if(flag)b+=firsth+all;
else a+=firsth+all;
flag=!flag;
}
else//白球没进洞
{
if(flag2)//有球进洞
{
if(flag3)//target
{
if(flag1)
{
if(flag)a+=all;
else b+=all;
}
else//没有先碰target进球了
{
if(flag)b+=all+firsth;
else a+=all+firsth;
flag=!flag;
}
}
else
{
if(!flag1)
{
if(flag)b+=firsth;
else a+=firsth;
}
if(flag)b+=all;
else a+=all;
flag=!flag;
}
}
else//没球进洞
{
if(!flag1)
{
if(flag)
b+=firsth;
else a+=firsth;
}
flag=!flag;
}
}
}
if(vis[_min])
{
while(vis[v[low]]&&low<=n)
{
low++;
}
_min=v[low];
}
}
printf("%d : %d\n",a,b);
}
return ;
}

(P.S.写的比较丑陋,分支可以优化)

zoj 3757 Alice and Bob and Cue Sports 月赛A 模拟的更多相关文章

  1. ZOJ 3757 Alice and Bob and Cue Sports(模拟)

    题目链接 题意 : 玩台球.Alice 和 Bob,一共可以进行m次,Alice 先打.有一个白球和n个标有不同标号的球,称目标球为当前在桌子上的除了白球以外的数值最小的球,默认白球的标号为0.如果白 ...

  2. zoj 3757 Alice and Bob and Cue Sports 模拟

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3757 #include<cstdio> #incl ...

  3. ZOJ 3757 Alice and Bod 模拟

    上次的ZJU月赛题,规则比较复杂,当时就连题意都没摸清楚,只觉得非常复杂 比完后敲啊敲啊敲,连续WA啊,该反思下自己,没按照题意来设置条件,题目中说了 白球入袋并且... 给对手加分 ,白球未入袋并且 ...

  4. ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)

    ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS     Memory Limit:262144KB     64bit IO For ...

  5. ZOJ 3529 A Game Between Alice and Bob 博弈好题

    A Game Between Alice and Bob Time Limit: 5 Seconds      Memory Limit: 262144 KB Alice and Bob play t ...

  6. 2014 Super Training #6 A Alice and Bob --SG函数

    原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...

  7. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  8. bzoj4730: Alice和Bob又在玩游戏

    Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...

  9. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

随机推荐

  1. jstl的formatNumber标签的四舍五入问题

    jstl的formatNumber标签的四舍五入问题 近日使用JSTL的formatNumber 标签进行四舍五入时,发现它竟然使用的是"4舍6入5奇偶"的算法. 要实现" ...

  2. iOS与Android通用AES加密

    找了很久才成功的aes 加密  服务器java写的 下载地址 https://pan.baidu.com/s/1nvi1zjr

  3. 使用methodSignatureForSelector与forwardInvocation实现消息转发 (转)

    转自:http://blog.sina.com.cn/s/blog_8c87ba3b0102v006.html 在给程序添加消息转发功能以前,必须覆盖两个方法,即methodSignatureForS ...

  4. Gulp那些好用的插件 2016.04.20

    开始接触LESS.组件化编程后,慢慢意识到需要一个提高工作效率的构建工具,就此接触到了Gulp. Gulp的好处在这里就不细说啦,只有四个API接口学起来简直爽歪歪,减少了大量的I/O操作,用起来很畅 ...

  5. centos7 玩aapt 安卓应用apk解包工具的安装

    最近在做一个应用市场的项目,需要在centos7下面对apk解包读取其信息,这就想到了使用Google的解包工具aapt,但是由于中国的原因,国内访问原生工具的地址就有些麻烦,这里就贴出地址:http ...

  6. NLPIR.user Not valid license or your license expired! Please feel free to contact pipy_zhang@msn.com

    NLPIR.user Not valid license or your license expired! Please feel free to contact pipy_zhang@msn.com ...

  7. iphone5手机端内容超出iphone6没问题且超出内容为http://.....网址

  8. new Image()的用途

    new Image()用途总结: 1.图片预加载      在做游戏时,为了使图片能快打开可以做预加载.      原理:创建image对象,将image对象的src分别指向需加载的图片地址,图片被请 ...

  9. ajax 异步上传视频带进度条并提取缩略图

    最近在做一个集富媒体功能于一身的项目.需要上传视频.这里我希望做成异步上传,并且有进度条,响应有状态码,视频连接,缩略图. 服务端响应 { "thumbnail": "/ ...

  10. jQuery 插件写法

    一.jQuery插件的类型 1. jQuery方法 很大一部分的jQuery插件都是这种类型,由于此类插件是将对象方法封装起来,在jQuery选择器获取jQuery对象过程中进行操作,从而发挥jQue ...