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

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<queue> #define MAXN 1050
#define PI acos(-1.0)
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,t) for(int i=s; i<=t; i++)
#define show(x) { cerr<<">>>"<<#x<<" = "<<x<<endl; }
#define showtwo(x,y) { cerr<<">>>"<<#x<<"="<<x<<" "<<#y<<" = "<<y<<endl; }
using namespace std; int n,m;
int a[MAXN],ans[];
bool used[MAXN*]; int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
while(cin>>n>>m)
{
memset(used,,sizeof(used));
a[] = ans[] = ans[] = ;
FOR(i,,n) scanf("%d",&a[i]);
sort(a+,a+n+); int cur = ,i = ;
while(m--) //去第i个球
{
while(used[a[i]]) i++; int p,q,p_largest ,q_sum;
bool target_in_p,target_in_q,cue_in_q;
q_sum = p_largest = ;
target_in_p = target_in_q = cue_in_q = ;
cin>>p;
FOR(j,,p)
{
int num; cin>>num;
p_largest = max(p_largest,num);
if(num == a[i]) target_in_p = true;
}
cin>>q;
FOR(j,,q)
{
int num; cin>>num;
if(num == a[i]) target_in_q = true;
if(num == ) cue_in_q = true;
else used[num] = true;
q_sum += num;
} bool foul = false;
if(p == )
ans[cur^] += a[i],foul = true;
else if( !cue_in_q && (!target_in_p || p > ))
ans[cur^] += p_largest,foul = true;
else if(cue_in_q)
ans[cur^] += p_largest,foul = true; if(!foul && target_in_q)
{
ans[cur] += q_sum;
cur ^= ;
}
else if((target_in_q && foul) || ( !target_in_q && q-cue_in_q > ) )
{
ans[cur^] += q_sum;
}
cur ^= ;
}
printf("%d : %d\n",ans[],ans[]);
}
}

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

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

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

  2. zoj 3757 Alice and Bob and Cue Sports 月赛A 模拟

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3757 题意:根据所给的台球规则,按照每次的结果计算最终两人的得分 ...

  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. Linux操作命令(一)

    ls 命令 ls 命令是 linux 下最常用的命令,ls 命令就是 list 的缩写. ls 用来打印出当前目录的清单.如果 ls 指定其他目录,那么就会显示指定目录里的文件及文件夹清单. 通过 l ...

  2. 字符编解码的故事 字符集 GBK GB2312 GB18030 Unicode 的由来和区别

    本文为转载. 很久很久以前,有一群人,他们决定用8个可以开合的晶体管来组合成不同的状态,以表示世界上的万物.他们认为8个开关状态作为原子单位很好,于是他们把这称为"字节". 再后来 ...

  3. ExtJS4加载FormPanel数据的几种方式

    我们做web应用最多的就是处理表单,extjs为我们提供了很多处理表单的功能,很多初学者疑惑怎么加载表单数据,到底能用什么方式加载?本文中,我将我自己实验过的进行一下总结,自己备忘,也希望能帮助到其他 ...

  4. cocos2d lua的cclog 在logcat中显示

    -- cclog cclog = function(...) release_print(string.format(...)) end 改成这样就可以了

  5. windows10 Build 10074版本上手体验(二)

  6. python 操作sqlite数据库

    '''SQLite数据库是一款非常小巧的嵌入式开源数据库软件,也就是说 没有独立的维护进程,所有的维护都来自于程序本身. 在python中,使用sqlite3创建数据库的连接,当我们指定的数据库文件不 ...

  7. 转 scrollLeft,scrollWidth,clientWidth,offsetWidth之完全详解

    scrollHeight: 获取对象的滚动高度. scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离 scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最 ...

  8. nutch 生产者队列的大小如何控制 threadcount * 50

    如果topN 设置为1000万 ,不会这1000万都放到QueueFeeder(内存)中,而是从文件系统中(hdfs)中迭代不断填充QueueFeeder.队列中默认存放 threadcount * ...

  9. JavaScript中的Function类型浅析

    1. Function类型是js中引用类型之一,每个函数实际上都是Function类型的实例对象,具有自己的属性和方法.正因为函数式对象,所以函数名实际上也是一个指向函数对象的指针. 2. 常用的函数 ...

  10. Android Integer.decode()和Intger.valueof()

    decode合适用来分析数字 可以分析 8进:010=>分析后为 8 10进:10=>分析后为 10 16进:#10|0X10|0x10=>分析后是 16 而valueof    只 ...