zoj 3757 Alice and Bob and Cue Sports
来源:互联网 发布:淘宝软文编辑技巧 编辑:程序博客网 时间:2024/06/07 01:42
模拟题,一定要根据题目意思!
#include <iostream>#include<cstring>#include<stdio.h>#include<algorithm>using namespace std;typedef struct ball{ int no,in; //球的编号,球是否在洞内}Ball;Ball goal_ball[1010];int b1[1010],b2[1010];int n,m;int cmp(const void * a, const void * b){ Ball* _a = (Ball*)a; Ball* _b = (Ball*)b; return _a->no - _b->no;}int get_goal() //查找目标球{ for(int i = 0;i < n;i++) { if(!goal_ball[i].in) { return goal_ball[i].no; } }}int main(){ int ans[2] ; while(scanf("%d %d",&n,&m)!= EOF) { ans[0] = 0,ans[1] = 0; int cur = 0; //0表示Alice击打,1表示Bob for(int i = 0; i < n;i++) { scanf("%d",&goal_ball[i].no); goal_ball[i].in = 0; } qsort(goal_ball,n,sizeof(Ball),cmp); int num1,num2; for(int i = 0; i < m;i++) { scanf("%d",&num1); //击球数 for(int j = 0;j < num1;j++) { scanf("%d",&b1[j]); } sort(b1,b1 + num1); scanf("%d",&num2); //进洞的球数 for(int j = 0;j < num2;j++) { scanf("%d",&b2[j]); } sort(b2,b2 + num2); int goal = get_goal(); int pen = 0; //没犯规 if(num1 == 0) //没有击中球 { cur = 1 - cur; ans[cur] += goal; pen = 1; } else if(num1 > 0 && num2 > 0 && b2[0] == 0) //击中球且母球入袋 { cur = 1 - cur; ans[cur] += b1[num1 - 1]; pen = 1; } else if(num1 > 1 || (num1 == 1 && b1[0] != goal)) //击中多余一个球或击中的不是目标球 { cur = 1 - cur; ans[cur] += b1[num1 - 1]; pen = 1; } else if (num2 == 0) //没犯规且没进球 { cur = 1 - cur; } if(num2 > 0) //进洞了 { if(pen) //犯规 { for(int j = 0 ; j < num2;j++) { ans[cur] += b2[j]; int temp = b2[j]; for(int k = 0;k < n;k++) { if(goal_ball[k].no == temp) goal_ball[k].in = 1; } } } else if(b2[0] != goal)//进洞的球中没有目标球 { cur = 1 - cur; for(int j = 0 ; j < num2;j++) { ans[cur] += b2[j]; int temp = b2[j]; for(int k = 0;k < n;k++) { if(goal_ball[k].no == temp) goal_ball[k].in = 1; } } } else //没犯规并且目标球进洞 { for(int j = 0 ; j < num2;j++) { ans[cur] += b2[j]; int temp = b2[j]; for(int k = 0;k < n;k++) { if(goal_ball[k].no == temp) goal_ball[k].in = 1; } } } } } printf("%d : %d\n",ans[0],ans[1]); } return 0;}
0 0
- zoj 3757 Alice and Bob and Cue Sports
- zoj 3757 Alice and Bob and Cue Sports 模拟
- zoj 3757 Alice and Bob and Cue Sports
- ZOJ 3757 Alice and Bob and Cue Sports [模拟]
- ZOJ 3757 Alice and Bob and Cue Sports
- ZOJ 3757 Alice and Bob and Cue Sports(模拟题)
- ZOJ3757:Alice and Bob and Cue Sports(模拟)
- ZOJ Problem Set - 3655 Alice and Bob
- ZOJ 3666 Alice and Bob(博弈)
- zoj 3666 Alice and Bob , SG函数
- ZOJ 3666 Alice and Bob 基础博弈
- Alice and Bob
- 2683. Alice and Bob
- 1798. Alice and Bob
- hdu4268 Alice and Bob
- HDU4268 Alice and Bob
- Alice, Bob and Chocolate
- hdu4268 Alice and Bob
- 文件系统IO---page cache与buffer cache
- URL and URI
- 《自己动手写操作系统》第三章 pmtest5源码解析——特权级变换与堆栈切换实例详解
- 从未安装APK中得到APK的Lable/ICON信息
- 软件项目管理-品质管理(一)
- zoj 3757 Alice and Bob and Cue Sports
- 13-14寒假作业12
- 重载内核全程分析笔记
- 对java 内存可见性的理解
- Android开发者需要面对的问题
- linux文件夹打包命令
- 为APP添加新的字体
- HDU 2159
- SVN提交小结