洛谷 题解 P2645 【斯诺克】
吐槽一下这道题:
数据太水了!!!
请注意,这题如果你考虑了犯规的情况,那么你的分数。。。可能会和我一样,只有40分。
也就是说,这是一篇AC不了这道题的题解!!!
现在,我来讲一下这道题的正解:
- 两个变量
less
和color
:less
记录剩余颜色为color
的球的个数,且场上没有颜色比less
小的球。 - 由题意,当场上没有红球时,第单数个球必须是红球
- 当场上有红球时,第双数个球必须是彩球,且击打不消耗个数。
- 当
less
为0
时,less = 0, color++;
给出处理某一个人的伪代码:
执行 n 次 {
记录上次球的颜色
读入这次球的颜色
如果 (这次球的颜色为 0) {
直接给对方加 4 分
} 否则 如果 (这是第单数个球 并且 红球没有打完) {
如果 (这次球的颜色不是 1) {
如果 (这次球的颜色对应的分数比 4 大) {
给对方加上这次球的颜色对应的分数
} 否则 {
给对方加 4 分
}
} 否则 {
给自己加 1 分
红球个数减 1
如果 (已经没有红球了) {
颜色加 1
该颜色个数置为 1
}
}
} else {
if ((上次打的不是红球 && 这次打的颜色比应该打的颜色大) || 这次打了红球) {
如果 (这次球的颜色对应的分数比 4 大) {
给对方加上这次球的颜色对应的分数
} 否则 {
给对方加 4 分
}
} else {
给自己加 这次球的颜色对应的分数 分
如果 (这个不是红球后面紧随的球) 该球个数减 1;
如果 (已经没有 color 颜色的球了) {
颜色加 1
该颜色个数置为 1
}
}
}
}
最终代码
/*
Name: Z*** Y* (H***Z*** J***L** Middle School, China)
Copyright: 航空信奥
Author: 航空信奥
Date: 2018-10-19
Description: the program that can solve snooker
*/
#include <queue>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using std::max;
using std::min;
using std::cerr;
using std::endl;
using std::sort;
using std::queue;
using std::vector;
using std::priority_queue;
struct fast_IO {
#define fast_IO_all_DEBUG 0
#define fast_IO_read_DEBUG 0
#define fast_IO_write_DEBUG 0
bool __read_sign_LowThan0;
char __read_buf_ch;
template <typename type>
void read(type &res)
{
__read_sign_LowThan0 = 0;
__read_buf_ch = getchar();
while (__read_buf_ch > '9' || __read_buf_ch < '0') {
__read_buf_ch = getchar();
if (__read_buf_ch == '-') {
__read_sign_LowThan0 = 1;
__read_buf_ch = getchar();
break;
}
}
res = (__read_buf_ch & 15);
__read_buf_ch = getchar();
while (__read_buf_ch <= '9' && __read_buf_ch >= '0') {
res = (res << 3) + (res << 1) + (__read_buf_ch & 15);
__read_buf_ch = getchar();
}
if (__read_sign_LowThan0) {
res = ((~res) + 1);
}
#if fast_IO_all_DEBUG || fast_IO_read_DEBUG
printf("[TEST $ read %d $ ]", res);
#endif
}
} io;
#define read io.read
#define write io.write
#define passing() fprintf(stderr, "passing line [%d] in function %s.\n", __LINE__, __FUNCTION__)
#define debug(x) cerr << "[debug] " << #x << " = " << x << endl
#define Max_N (107)
#define Max_M
#define Max_K
#define Max_LogN
#define Max_LogM
#define Max_LogK
int n, m, k;
#define P 10007
int a[Max_N] = {0};
bool used[Max_N] = {false};
#define FILE
int color = 1;
int less = 15;
void doit(int &n, int &mine, int &your)
{
int t, las;
for (int i = 1; i <= n; i++) {
las = t;
read(t);
if (!t) {
your += 4;
} else if ((i & 1) && color == 1) {
if (t != 1) {
if (t > 4) {
your += t;
} else {
your += 4;
}
} else {
mine++;
less--;
if (less == 0) {
color++;
less = 1;
}
}
} else {
if ((las != 1 && t > color) || t == 1) {
if (t > 4) {
your += t;
} else {
your += 4;
}
} else {
mine += t;
if (las != 1 && color != 1) less--;
if (less == 0) {
color++;
less = 1;
}
}
}
// printf("ball %d: %d:%d [color = %d eith %d in low]\n", t, mine, your, color, less);
}
}
int main()
{
#ifdef FILE
freopen("snooker.in", "r", stdin);
freopen("snooker.out", "w", stdout);
#endif
read(n);
read(m);
int ansa(0), ansb(0);
doit(n, ansa, ansb);
doit(m, ansb, ansa);
printf("%d %d", ansa, ansb);
return 0;
}
洛谷 题解 P2645 【斯诺克】的更多相关文章
- P2645 斯诺克 题解
P2645 斯诺克 题目背景 镇海中学开设了很多校本选修课程,有体育类.音乐类.美术类.无线电测向.航空航海航天模型制作等,力争使每位学生高中毕业后,能学到一门拿得出手的兴趣爱好,为将来的终身发展打下 ...
- 洛谷 题解 UVA572 【油田 Oil Deposits】
这是我在洛谷上的第一篇题解!!!!!!!! 这个其实很简单的 我是一只卡在了结束条件这里所以一直听取WA声一片,详细解释代码里见 #include<iostream> #include&l ...
- 洛谷 题解 P1600 【天天爱跑步】 (NOIP2016)
必须得说,这是一道难题(尤其对于我这样普及组205分的蒟蒻) 提交结果(NOIP2016 天天爱跑步): OJ名 编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间 Libre ...
- 洛谷题解P4314CPU监控--线段树
题目链接 https://www.luogu.org/problemnew/show/P4314 https://www.lydsy.com/JudgeOnline/problem.php?id=30 ...
- 洛谷题解 CF777A 【Shell Game】
同步题解 题目翻译(可能有童鞋没读懂题面上的翻译) 给你三张牌0,1,2. 最初选一张,然后依次进行n次交换,交换规则为:中间一张和左边的一张,中间一张和右边一张,中间一张和左边一张...... 最后 ...
- 洛谷题解 CF807A 【Is it rated?】
同步题解 题目 好吧,来说说思路: 1.先读入啦~(≧▽≦)/~啦啦啦 2.判断a[i]赛前赛后是否同分数,如果分数不同,则输出,return 0 . 3.如果同分数,则判断a[i]赛前(或赛后)是否 ...
- 洛谷题解 P1138 【第k小整数】
蒟蒻发题解了 说明:此题我用的方法为桶排(我翻了翻有人用了桶排只不过很难看出来,可能有些重复的,这个题只是作为一个专门的桶排来讲解吧) (不会算抄袭吧 ‘QWaWQ’) 简单来说(会的人跳过就行): ...
- 【洛谷题解】P2303 [SDOi2012]Longge的问题
题目传送门:链接. 能自己推出正确的式子的感觉真的很好! 题意简述: 求\(\sum_{i=1}^{n}gcd(i,n)\).\(n\leq 2^{32}\). 题解: 我们开始化简式子: \(\su ...
- 洛谷题解 P2865 【[USACO06NOV]路障Roadblocks】
链接:https://www.luogu.org/problemnew/show/P2865 题目描述 Bessie has moved to a small farm and sometimes e ...
随机推荐
- 数据仓库ETL案例学习(一)
来自课程案例学习 某跨国食品超市的信息管理系统,每天都会记录成千上万条各地连锁超市的销售数据.基于大数据的背景,该公司的管理层决定建立FoodMart数据仓库,期望能从庞大的数据中挖掘出有商业价值 ...
- 网站搭建-虚拟机的使用-Linux (包括输入法和QQ下载使用)
之前已经联网了,基本的软件系统会自己下载,先不用管. 1. 先下载一个中文输入法吧: 先改一下Firefox的搜索引擎吧,因为大陆不支持google 下载,安装,就完事了,还好这个没变,几年不用这个系 ...
- [LC]219题 Contains Duplicate II (存在重复元素 II )
①英文题目: Given an array of integers and an integer k, find out whether there are two distinct indices ...
- 易语言 史诗级Json处理 烁_Json模块!!!!
大家好,我是键盘上的魔手 * “************************”* “** 欢迎使用烁Json模块 **”* “** 作者:键盘上的魔手 **”* “** 微信号:codervip ...
- nyoj 655-光棍的yy (python, 未A)
655-光棍的yy 内存限制:64MB 时间限制:1000ms 特判: No 通过数:4 提交数:7 难度:2 题目描述: yy经常遇见一个奇怪的事情,每当他看时间的时候总会看见11:11,这个很纠结 ...
- Vue2.x与bootsrap-table动态添加元素和绑定事件无效
一.问题: 最近在使用vue与bootstrap-table结合生成表格时,按以前的经验----每列数据可用formatter:function(value,row,index){}进行一些其 ...
- django_4数据库2——表外键
表关系: many to one many to many one to one many to one 记录是如何创建出来的? 先创建one,在在创建many,创建时加入ForeignKe ...
- 2019-10-9:渗透测试,基础学习the-backdoor-factory-master(后门工厂)初接触
该文章仅供学习,利用方法来自网络文章,仅供参考 the-backdoor-factory-master(后门工制造厂)原理:可执行二进制文件中有大量的00,这些00是不包含数据的,将这些数据替换成pa ...
- oracle内存占用过高和修改不当无法启动oracle实例的解决办法
今天,在自己机器上装了oracle 12c,发现Oracle的服务Oracle RDBMS Kenel Executable (OracleServiceORCL)占用内存高达5G,本人电脑内存才1 ...
- win到linux的编码问题
从windows到linux的文件可能存在编码问题时,这是因为,Linux和Windows文本文件的行结束标志不同.在Linux中,文本文件用"\n"表示回车换行,而Windows ...