当前位置: 首页 > news >正文

Codeforces 101487E - Enter The Dragon

101487E - Enter The Dragon

思路:做的时候两个地方理解错了,第一个事我以为龙吸了水,水就干了,其实龙是在下雨之前吸的,下雨时湖水又满了,所以湖水永远不会干;第二个是以为只要找前面一段没下雨的天吸水就可以了,其实是上一次满了之后没下雨的天吸水都可以。

代码:

 

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

const int N=1e6+5;
set<int>s;
int a[N];
int ans[N];
int pre_full_pos[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t,n,m;
    cin>>t;
    while(t--)
    {
        cin>>n>>m;
        for(int i=0;i<m;i++)cin>>a[i];
        s.clear();
        mem(pre_full_pos,0);
        mem(ans,0);
        bool flag=false;
        for(int i=0;i<m&&!flag;i++)
        {
            if(a[i])
            {
                set<int>::iterator it=s.lower_bound(pre_full_pos[a[i]]);
                if(it!=s.end())
                {
                    ans[*it]=a[i];
                    s.erase(it);
                    pre_full_pos[a[i]]=i;
                }
                else flag=true;
            }
            else s.insert(i); 
        }
        if(flag){
            cout<<"NO"<<endl;
            continue;
        }
        cout<<"YES"<<endl;
        for(int i=0;i<m;i++)if(!a[i])cout<<ans[i]<<' ';
        cout<<endl; 
    }
    return 0;
}
/*
10
4 10
0 0 3 4 0 0 1 0 4 3 
*/

 

转载于:https://www.cnblogs.com/widsom/p/7668341.html

相关文章:

  • JS报错:Cannot read property 'type' of undefined
  • Rac修改IP(不同网段)的方法步骤
  • Java 8 Distinct by property
  • [译] Swift 中关于并发的一切:第一部分 — 当前
  • js的属性事件
  • 网络请求框架 Retrofit 2 使用入门
  • cpu,io密集型计算概念
  • ubuntu 安装dlib 出现dlib.so: undefined symbol: png_set_longjmp_fn
  • 第三讲课后作业1
  • 购物车优化
  • 《用数据讲故事》作者Cole N. Knaflic:消除一切无效的图表
  • spring mvc 配置文件加载
  • 用canvas实现一个colorpicker
  • JDK8新特性(2):Stream API常用操作
  • BZOJ 2457 [BeiJing2011] 双端队列
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • Android组件 - 收藏集 - 掘金
  • Apache的80端口被占用以及访问时报错403
  • Java知识点总结(JavaIO-打印流)
  • LintCode 31. partitionArray 数组划分
  • 初识 beanstalkd
  • 从 Android Sample ApiDemos 中学习 android.animation API 的用法
  • 大数据与云计算学习:数据分析(二)
  • 官方解决所有 npm 全局安装权限问题
  • 机器学习中为什么要做归一化normalization
  • 计算机常识 - 收藏集 - 掘金
  • 技术攻略】php设计模式(一):简介及创建型模式
  • 线上 python http server profile 实践
  • Spring第一个helloWorld
  • 交换综合实验一
  • ​linux启动进程的方式
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • #laravel 通过手动安装依赖PHPExcel#
  • $(function(){})与(function($){....})(jQuery)的区别
  • (PyTorch)TCN和RNN/LSTM/GRU结合实现时间序列预测
  • (转)iOS字体
  • (转)关于pipe()的详细解析
  • ..thread“main“ com.fasterxml.jackson.databind.JsonMappingException: Jackson version is too old 2.3.1
  • .NET Core WebAPI中使用Log4net 日志级别分类并记录到数据库
  • .net wcf memory gates checking failed
  • .NET 指南:抽象化实现的基类
  • .net遍历html中全部的中文,ASP.NET中遍历页面的所有button控件
  • .pop ----remove 删除
  • /etc/sudoers (root权限管理)
  • /proc/interrupts 和 /proc/stat 查看中断的情况
  • @RequestMapping-占位符映射
  • [Android] 修改设备访问权限
  • [Android开源]EasySharedPreferences:优雅的进行SharedPreferences数据存储操作
  • [BZOJ1053][HAOI2007]反素数ant
  • [C#] 如何调用Python脚本程序
  • [C#]C# winform实现imagecaption图像生成描述图文描述生成
  • [ComfyUI进阶教程] animatediff视频提示词书写要点
  • [CSS] - 修正IE6不支持position:fixed的bug
  • [CSS]盒子模型
  • [CSS]中子元素在父元素中居中