传送门

因为一个等号挂掉了10pts

发现每个黑色段一定对应了一段不可行的出发区间

检查是否存在所有黑色段的并集的补集即可

具体来说,我们对于每个黑色段计算出一个(有的是两个)区间 \([l, r]\) ,把它们全合并,看有没有剩下的位置

Code:

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define N 500010
#define ll long long
//#define int long long char buf[1<<21], *p1=buf, *p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf, 1, 1<<21, stdin)), p1==p2?EOF:*p1++)
inline int read() {
int ans=0, f=1; char c=getchar();
while (!isdigit(c)) {if (c=='-') f=-f; c=getchar();}
while (isdigit(c)) {ans=(ans<<3)+(ans<<1)+(c^48); c=getchar();}
return ans*f;
} int n; ll s, k;
ll a[N]; namespace force{
bool lim[N]; ll ento;
bool check(int b) {
ll now=b;
while (now<ento) {
now+=k;
if (lim[now]) return 0;
}
return 1;
}
void solve() {
ento=0;
memset(lim, 0, sizeof(lim));
for (int i=1; i<=n; ++i) {
//cout<<"goto lim: "<<ento+1<<' '<<ento+a[i]+s<<endl;
if (i&1) for (int j=ento+1; j<ento+a[i]+s; ++j) lim[j]=1;
ento+=a[i];
}
//cout<<"lim: "; for (int i=0; i<=ento; ++i) cout<<lim[i]<<' '; cout<<endl;
//cout<<"check: "; for (int i=0; i<=k; ++i) cout<<check(-i)<<' '; cout<<endl;
for (int i=0; i<=k; ++i)
if (check(-i)) {puts("TAK"); return ;}
puts("NIE");
}
} namespace task1{
struct range{ll l, r; inline void build(ll a, ll b) {l=a; r=b;}}ran[N];
inline bool operator < (range a, range b) {return a.l<b.l;}
void solve() {
ll now=0; int top=0;
for (int i=1; i<=n; ++i) {
if (i&1) {
if (1ll*a[i]+s>k) {puts("NIE"); return ;}
//cout<<"limit: "<<now+1<<' '<<now+a[i]+s-1<<endl;
ll t1=ceil((1.0*now+1)/(1.0*k)+1e-8);
ran[++top].build(now+1-t1*k, now+a[i]+s-1-t1*k);
if (now+a[i]+s-1-t1*k>=0) {
++t1;
ran[++top].build(now+1-t1*k, now+a[i]+s-1-t1*k);
}
}
now+=a[i];
}
sort(ran+1, ran+top+1);
//cout<<"ran: "<<endl; for (int i=1; i<=top; ++i) cout<<ran[i].l<<' '<<ran[i].r<<endl;
for (int i=2; i<=top; ++i) {
//cout<<"i: "<<i<<endl;
if (ran[i-1].r+1>=ran[i].l) ran[i].l=ran[i-1].l, ran[i].r=max(ran[i-1].r, ran[i].r);
else {puts("TAK"); return ;}
}
//assert(top==1);
//cout<<"top: "<<ran[top].l<<' '<<ran[top].r<<endl;
if ((ran[top].l>=-k&&ran[top].r<-1) || (ran[top].l>-k&&ran[top].r<0)) {puts("TAK"); return ;}
puts("NIE");
}
} signed main()
{
int T; T=read();
while (T--) {
s=read(); k=read(); n=read();
for (int i=1; i<=n; ++i) a[i]=read();
//force::solve();
task1::solve();
} return 0;
}

题解 Emotional Flutter的更多相关文章

  1. csp-s模拟47 Emotional Flutter,Endless Fantasy题解

    题面:https://www.cnblogs.com/Juve/articles/11558523.html A:Emotional Flutter 如果起点确定,那么我们后面走的点都是固定的,及mo ...

  2. jzoj5832. 【省选模拟8.20】Emotional Flutter

    tj:我們發現,每一次走過的步長都是k,設當前走的步數是x,走到了一個白條 那麼,每一次走就是把所有黑條都向前移k位,我們可以考慮把所有黑條的左邊界不斷的向前移動k,直到下一次移動時,其左邊界小於0, ...

  3. [CSP-S模拟测试]:Emotional Flutter(贪心)

    题目传送门(内部题51) 输入格式 第一行一个整数$t$表示数据组数.每组数据的第一行有三个整数$s,k,n$.第二行有$n$个整数$A_1,A_2,...,A_n$,依次表示黑白条的长度. 输出格式 ...

  4. 20210819 Emotional Flutter,Medium Counting,Huge Counting,字符消除2

    考场 T1 一下想到了这题,将白块缩短 \(s\) 后维护类似的区间即可. T2 T3 俩计数,直接跳了. T4 的可行 \(t\) 集合相同相当与从 \(n\) 往前跳 kmp 数组,途径点相同,从 ...

  5. [CSP-S模拟测试47]反思+题解

    打开题面,T3似乎被换过了.(那我就更有理由直接弃掉了) T1是我最害怕的乱搞题,赶紧扔了看T2.发现是个sb板子?雨天的尾巴弱化版? 然而线段树合并早忘干净了(最近几道可以线段树合并的题都是用别的方 ...

  6. 2019.9.19 csp-s模拟测试47 反思总结

    思路接近正解?都想到了?这都是借口呀. 没有用的,往前走吧. T1:Emotional Flutter 我的做法和题解不太一样,我把s放在最后考虑了. 因为出发以后步幅是一样的,所以每一个黑条可以ba ...

  7. noip模拟44[我想我以后会碰见计数题就溜走的]

    noip模拟44 solutions 这一场抱零的也忒多了,我也只有45pts 据说好像是把几套题里面最难的收拾出来让我们考得 好惨烈啊,这次的考试我只有第一题骗了40pts,其他都抱零了 T1 Em ...

  8. 2021.8.19考试总结[NOIP模拟44]

    T1 emotional flutter 把脚长合到黑条中. 每个黑条可以映射到统一区间,实际操作就是左右端点取模.长度大于$k$时显然不合法. 然后检查一遍区间内有没有不被黑条覆盖的点即可. 区间端 ...

  9. CSPS模拟 47

    考试时T1没玩明白,用一个WA90把100盖住了? T1 Emotional Flutter 题目非常蠢萌,只是注意当你把黑块前伸s距离后,应把脚的长度视为0,而不应为1. T2 Endless Fa ...

随机推荐

  1. Spring Cloud中的注解

    一.Eureka @EnableEurekaServer: @EnableDiscoverClient:标注服务是一个Eureka的客户端 @LoadBalanced:自动构造LoadBalancer ...

  2. python django与celery的集成

    一.celery与django 关于celery介绍和使用可以查看上篇Python中任务队列-芹菜celery的使用 关于django的介绍和使用可查看python django框架+vue.js前后 ...

  3. WSL2:在Windows系统中开发Linux程序的又一神器

    作 者:道哥,10+年的嵌入式开发老兵. 公众号:[IOT物联网小镇],专注于:C/C++.Linux操作系统.应用程序设计.物联网.单片机和嵌入式开发等领域. 公众号回复[书籍],获取 Linux. ...

  4. 计算机毕业设计选题大合集,含ssm,springboot,小程序,php,python

    1基于springboot医院急诊系统 2基于springboot校园闲置物品租售系统 3基于springboot校园闲置物品交易网站 4基于springboot图书网站 5基于springboot外 ...

  5. python + mysql 实现查询表数据

    实例如下: import pymysqldef select_form(): # 打开数据库连接 db = pymysql.connect("localhost", "r ...

  6. Leetcode:1008. 先序遍历构造二叉树

    Leetcode:1008. 先序遍历构造二叉树 Leetcode:1008. 先序遍历构造二叉树 思路 既然给了一个遍历结果让我们建树,那就是要需要前序中序建树咯~ 题目给的树是一颗BST树,说明中 ...

  7. element取消全局loading

    背景 前两天在开发一个管理后台项目时, 遇到了一个问题,后端接口返回特别慢,由于该接口调用的是第三方API,无法通过后端去处理.此时想到用loading动画,但随之而来也产生了不少问题, 在此记录一下 ...

  8. 规模化敏捷LeSS(二):LeSS*队实践指南

    Scrum 能够帮助一个5-9人的小*队以迭代增量的方式开发产品,在每一迭代结束时,交付潜在的可交付的产品增量.正是由于其灵活性,Scrum 方法现已成为*队软件交付方法的首选,近期发布的15届敏捷状 ...

  9. 第一篇 -- 安装和配置PyQt5

    我的电脑环境是:Win10 + Python3.6.4 + JetBrains PyCharm 2017.3.2 x64 之前用tkinter写界面,现在学习如何用PyQt5写界面. 安装PyQt5: ...

  10. tp phpexcel 导入后台访问方法

    public function addall(){ $Water = M('Waterrate'); $config = array( 'maxSize' => 0, 'rootPath' =& ...