传送门

因为一个等号挂掉了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. angular小记

    declarations:包装组件或指令等 providers:依赖注入 imports:导入其他模块 bootstrap:设置根组件 exports:导出组件或指令等 app.component.t ...

  2. STM32中STD、HAL、LL库比较

    ST为开发者提供了标准外设库(STD库).HAL库.LL库 三种.前两者都是常用的库,后面的LL库是ST新添加的,随HAL源码包一起提供,目前支持的芯片也偏少. 标准外设库(Standard Peri ...

  3. 论文阅读:hector_slam: A Flexible and Scalable SLAM System with Full 3D Motion Estimation.

    参考:<A Flexible and Scalable SLAM System with Full 3D Motion Estimation.> 该论文是ROS中hector_mappin ...

  4. linux系统安装+windows系统安装

    linux 1.格式化U盘 打开管理员命令提示符 diskpart list disk select disk 2 clean create partition primary format fs=f ...

  5. Linux CentOS 7 安装配置vsftp

    学习Linux时间不长,首次安装了vsftp,按照网上的各种帖子尝试配置,不过都没打到预期,不是被拒绝连接,就是连接超时,总之就是各种问题啊.当然了,不是别人配置的不对,而是自己不是太懂Linux,选 ...

  6. nmcli命令行修改网络连接名称

    目前在网上能找到的文章中,使用nmcli命令修改Linux系统中网卡连接的名称都是先创建新的连接,然后删除旧的连接的方式 此种方式其实完全不恰当,简直就是在浪费时间,nmcli命令本身就提供了直接修改 ...

  7. node fs-extra文件操作模块的使用(支持同步、异步)

    用法参见:fs-extra

  8. 【LeetCode】204.计数质数

    问题描述: 统计所有小于非负整数 n 的质数的数量. 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 . 这是一道简单题,但是却并没有那么直 ...

  9. Spring WebFlux 基础教程:参数校验

    请求参数校验,在实际的应用中很常见,网上的文章大部分提供的使用注解的方式做参数校验.本文主要介绍 Spring Webflux Function Endpoint 使用 Spring Validati ...

  10. SpringBoot @ModelAttribute 用法

    前言 项目中遇到这么一个使用场景,用户的登录信息给予token保存,在需要有登录信息的地方,每次都要去获取用户Id,但每次在请求方法中去获取用户信息,代码重复,冗余,很low于是想到了用@ModelA ...