题目链接: 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. 解决lucene 重复索引的问题

    在使用Lucene过程中,会发现当我们为添加新的Document时,会产生重复现象(两次添加同一个Document),毕竟Lucene中没有像数据库中一样,有键可以区分.不过我们可以通过为Docume ...

  2. FontDialog组件设置字体

    1.设置字体 private void button3_Click(object sender, EventArgs e) { this.fontDialog1.ShowDialog(); this. ...

  3. 制作按钮(Button)

    按钮的核心作用 1.按钮能接收单击并触发响应事件. 2.按钮被单击时能同时触发多个响应事件. 3.按钮可以有普通.悬停.单击.禁用等多个状态的不同表现. 4.广泛的说,按钮的核心在于接收事件,任何可以 ...

  4. cocos2dx伸缩式列表效果

    效果: 代码: ElasticListView.h #pragma once //std #include <string> #include <map> //cocos #i ...

  5. hdu 3303 Harmony Forever (线段树 + 抽屉原理)

    http://acm.hdu.edu.cn/showproblem.php?pid=3303 Harmony Forever Time Limit: 20000/10000 MS (Java/Othe ...

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

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

  7. IntelliJ IDEA 13怎么创建JAVA SE项目

    如下图,直接下一步,如果需要的话可以选择建立Main函数:

  8. SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-008-带参数的ADVICE

    一. 假设有情形如:cd里有很多轨,当播放音乐时,要统计每个音轨的播放次数,这些统计操作不应放在播放方法里,因为统计不是播放音乐的主要职责,这种情况适合应用AOP. 二. 1. package sou ...

  9. ANDROID_MARS学习笔记_S02_001_Spinner

    1.strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> < ...

  10. QT做界面真是绝美,并且还可嵌入HTML与JS做界面(许多案例)

    1. 这年头想要酷炫, 还是用web最方便, QT自带嵌入式webkit, 然后用d3.js D3.js - Data-Driven Documents什么的, 各种酷炫的互动表随手而来.这里有各种各 ...