zoj 3757 Alice and Bob and Cue Sports 模拟
题目链接: 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 模拟的更多相关文章
- ZOJ 3757 Alice and Bob and Cue Sports(模拟)
题目链接 题意 : 玩台球.Alice 和 Bob,一共可以进行m次,Alice 先打.有一个白球和n个标有不同标号的球,称目标球为当前在桌子上的除了白球以外的数值最小的球,默认白球的标号为0.如果白 ...
- zoj 3757 Alice and Bob and Cue Sports 月赛A 模拟
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3757 题意:根据所给的台球规则,按照每次的结果计算最终两人的得分 ...
- ZOJ 3757 Alice and Bod 模拟
上次的ZJU月赛题,规则比较复杂,当时就连题意都没摸清楚,只觉得非常复杂 比完后敲啊敲啊敲,连续WA啊,该反思下自己,没按照题意来设置条件,题目中说了 白球入袋并且... 给对手加分 ,白球未入袋并且 ...
- 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 ...
- 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 ...
- 2014 Super Training #6 A Alice and Bob --SG函数
原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最 ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- bzoj4730: Alice和Bob又在玩游戏
Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合 ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
随机推荐
- Java线程(转)
1.Java线程的实现. 第一种方式可以通过继承Thread.在Thread类中,有许多关于线程操作的方法,比如:sleep();activeCount();等 继承Thread的代码: public ...
- bug - colorWithPatternImage:
// 在ios5之前, 再通过以下方法设置背景时, 有闪屏bug self.view.backgroundColor = [UIColor colorWithPatternImage:<#(no ...
- 【弱省胡策】Round #6 String 解题报告
感觉这个题好神啊. 首先我们只管 $a = b$ 的情况,那么我们自然就可以把这个串对 $a$ 取模,然后用 KMP 求出能弄出几个其他的 B 串. 具体就是把串先倍长,然后倒过来,然后求 $Next ...
- sjtu1364 countcountcount
Description 我有一个元素个数为\(n\)的整数数组\(a\)和\(Q\)个问题,每个问题有\(x,y\)两个参数,我要数有多少个整数\(K\)满足\(K\)在\(a[x]-a[y]\)中出 ...
- codeforces 392A Blocked Points
我的方式是用暴力的方法找到每一行每一列的边界点: 但是有大神直接用一个公式解决了:floor(n*sqrt(2))*4: 想了很久还是不理解,求各路大神指点! #include<iostream ...
- 【Firefly API 新版文档】Package dbentrust
原地址:http://blog.csdn.net/uxqclm/article/details/11969653 该包下面主要是数据库的处理与memcached存储.里面封装了,从memcached数 ...
- [codility]Grocery-store
http://codility.com/demo/take-sample-test/hydrogenium2013 用Dijkstra求最短路径,同时和D[i]比较判断是不是能到.用了优先队列优化,复 ...
- 在ubuntu系统荣品开发配套JDK安装
chmod 755 jdk-6u29-linux-i586.bin ./jdk-6u29-linux-i586.bin
- hdu4293Groups
http://acm.hdu.edu.cn/showproblem.php?pid=4293 这题单拉出来写篇吧 确实不错的一题 将每个人说的话 转化一下 可以算出它处在哪个段中 题目就转换成了求不相 ...
- 基于WebForm+EasyUI的业务管理系统形成之旅 -- 系统设置(Ⅰ)
上篇<基于WebForm+EasyUI的业务管理系统形成之旅 -- 总体介绍>,主要介绍系统总体的界面效果和用户体验UI设计. 在MVC.MVP大行其道的今天,写WebForm该系列篇章, ...