题目链接: 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. 【BZOJ】1925: [Sdoi2010]地精部落 DP+滚动数组

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1925 题意:输入一个数N(1 <= N <= 4200),问将这些数排列成折线 ...

  2. 【Bean】 这才是bean,一直没仔细看

    EJB是Enterprise Java Bean的缩写,一个Bean扮演着应用程序素材的角色.它包含有一个functional interface,一个life-cycle interface,以及一 ...

  3. 成为Java GC专家(3)—如何优化Java垃圾回收机制

    为什么需要优化GC 或者说的更确切一些,对于基于Java的服务,是否有必要优化GC?应该说,对于所有的基于Java的服务,并不总是需要进行GC优化,但前提是所运行的基于Java的系统,包含了如下参数或 ...

  4. ssh中使用set的地方及ref

    22:30 2014/5/2 1.层与层间的set:  xml方式:在action中曾有service的set方法,service层要有dao的service的set方法,dao曾要有hibernat ...

  5. 解决websphere在aix linux下日志乱码

    管理控制台--->服务器--->应用程序服务器--->server1--->java和进程管理--->进程定义--->java虚拟机--->将通用jvm参数设 ...

  6. var a=[]; 和 var a=new Array(); 的区别,为什么前者效率高

    因为 JSON格式的语法是引擎直接解释的.而new Array 则需要调用Array的构造器.还有就是1.当你需要将一个数字转化为字符串时可以这样定义:var s=""+1; 这样 ...

  7. Android笔记5-与USB HID 设备通信(一)

    1.了解 支持USB 主机(host)或者从机(accessary )模式最终是取决于设备的硬件,而与平台版本无关.我们可以通过usesfeature这个方法来查询自己的设备是否支持USB主从.   ...

  8. 第一章 USB Type C的基本原理

    图 1: USB Type C接头外形 USB Type C(简称USB-C)的基本特性: 1. 接口插座的尺寸与原来的Micro USB规格一样小,约为8.3mm X 2.5mm 2. 可承受1万次 ...

  9. gif录制工具

    gif录制工具 This tool allows you to record a selected area of your screen and save it as a Gif. http://s ...

  10. Android-锁屏功能

    当屏幕多久没有点击的时候,进行某种操作就是所谓的锁屏功能. onCreate: public void addRunnable() { handler.postDelayed(runnable, Co ...