Codeforces Round #381 (Div. 2)C - Alyona and mex

PLC中干湿球湿度计算:从原理到工程落地 温度参数的采集与控制是现代工业自动化系统的基础环节,而湿度作为环境控制中的关键指标,其测量方式在PLC工程实践中呈现出多样化的技术路径。干湿球测湿法是一种经典且经济的湿度测量方案,其核心原理基于干球温度与湿球温度之间的差值,结合饱和水汽压模型实现相对湿度的求解。该方案在暖通空调、农业大棚、洁净车间等场景中具有广泛的应用价值,尤其适合对长期稳定性和可维护性有较高要求的控制系统。在PLC平台上实现干湿球湿度计算,既可通过Magnus经验公式完成浮点运算,也可采用标准的二维湿度查算表配合数据块查表实现,工程中还需 阅读详情
C. Alyona and mex
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special.

Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers li and ri, and its elements are a[li], a[li + 1], ..., a[ri].

Alyona is going to find mex for each of the chosen subarrays. Among these m mexes the girl is going to find the smallest. She wants this minimum mex to be as large as possible.

You are to find an array a of n elements so that the minimum mex among those chosen by Alyona subarrays is as large as possible.

The mex of a set S is a minimum possible non-negative integer that is not in S.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105).

The next m lines contain information about the subarrays chosen by Alyona. The i-th of these lines contains two integers li and ri(1 ≤ li ≤ ri ≤ n), that describe the subarray a[li], a[li + 1], ..., a[ri].

Output

In the first line print single integer — the maximum possible minimum mex.

In the second line print n integers — the array a. All the elements in a should be between 0 and 109.

It is guaranteed that there is an optimal answer in which all the elements in a are between 0 and 109.

If there are multiple solutions, print any of them.

Examples
input
5 3
1 3
2 5
4 5
output
2
1 0 2 1 0
input
4 2
1 4
2 4
output
3
5 2 0 1
Note

The first example: the mex of the subarray (1, 3) is equal to 3, the mex of the subarray (2, 5) is equal to 3, the mex of the subarray (4, 5)is equal to 2 as well, thus the minumal mex among the subarrays chosen by Alyona is equal to 2.


大体题意是要构造一个序列,使得他给你的那m个查询区间里的最小的mex最大化,mex是不在这个区间里的最小非负数,要使最小的最大化,最小的那个应该是区间范围长度最小的,让他最大化,最大也就是区间的长度,确定好了这个最小值,就可以构造了。。。。。

假设已经确定好了那个最小值是x,

序列:0 1 2 ... x-1 0 1 2 ...x-1 ........一直有n个点,

为什么这么构造呢。。。。不会推理,灵光一现。。证明就很简单了,能看出来,对于这个序列,区间长度大于等于x的区间,无论怎么覆盖都肯定能至少把0~x-1覆盖一遍

#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
	int i,t,n,m,l,r,minn=inf;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&l,&r);
		minn=min(minn,r-l);
	}
	minn++;
	printf("%d\n",minn);
	for(t=0,i=0;i<n;i++)
	{
		if(t==minn)
		{
			t=0;
		}
		printf("%d",t);
		t++;
		if(i==n-1)
		printf("\n");
		else
		printf(" ");
	}
}

第一次cf排名这么高。。。。。。。虽然我菜,但是我水啊

【2026OD新机考】【哈希表】20260422-文章特征提取【Py/Java/C++/C/JS/Go六种语言OD真题】【欧弟算法】全网注释最详细分类最全的华子OD真题题解 90+天陪伴式学习,100+直播课时,300+动画图解视频,500+LeetCode经典题,500+华为OD真题/大厂真题,还有简历修改、模拟面试、陪伴小群、资深HR对接将为你解锁。这道题的本质是多集合交集问题的变形,属于非常典型的哈希表应用题。,储存全局的每个片段中,各个字符最少出现的次数。表示该字母并非所有片段的公共字母。,按照顺序构建答案即可。没有字母在所有三个字符串中都出现。每个字母在各字符串中都至少出现。次,所以结果中每个字母出现一次。这样,当上述循环结束后,最终。显然在上述代码中,如果字母。 阅读详情

相关推荐

从零开始使用matlab实现EKF-SLAM算法(含完整代码)

扩展卡尔曼滤波器同步定位与建图 (EKF-SLAM) 算法建立在 EKF 的基础上,集成了 EKF 的功能,可解决机器人技术中最具挑战性的问题之一:同时定位与建图 (SLAM)。 EKF-SLAM采用EKF方法来同时估计机器人的状态和周围环境的布局,而无需事先了解位置。 这种双重功能对于在未知环境中运行的自主系统至关重要,使它们能够在绘制区域地图时有效导航。 EKF-SLAM 算法一直是自动驾驶车辆和机器人系统开发的基石,为处理现实世界环境中固有的不确定性提供了一个强大的框架。

mjmmm的博客 6649

codeforces 构造 Alyona and mex

codeforces 构造 Alyona and mex

m0_62031207的博客 271

HarmonyOS NEXT 开发者预览版Beta招募应知测试

本次HarmonyOS NEXT 开发者预览版 Beta 招募活动为开发者预览版尝鲜升级,主要供开发者进行应用调测使用,除部分系统应用外,其他所有应用将被清除,因此在进行HarmonyOS NEXT 开发者预览版升级前,需进行数据备份。通过应知测试,并提交了参加HarmonyOS NEXT 开发者预览版招募 Beta 活动的报名信息,就会立刻审核通过并且收到新版本。手机在参加HarmonyOS NEXT 开发者预览版 Beta 招募活动前,需要对应机型升级到招募要求对应的基线版本,并预留内存空间。

长久公子的博客 8655

CodeForces 740C - Alyona and mex(思维)

C. Alyona and mex time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona’s mother wants to present an array of n non-negative integers to

Snakeflute的博客 652

可变形卷积(Deformable Conv)原理解析与torch代码实现

图6为可变形卷积示意图。图1所示为普通卷积在输入特征图上进行卷积计算的过程,卷积核大小为3*3,在输入特征图尺寸为7*7上进行卷积,将卷积核权重与输入特征图对应位置元素相乘并求和得到输出特征图元素,按一定方式滑动窗口就能计算得到整张输出特征图。图6所示,在input feature map上普通卷积操作对应卷积采样区域是一个卷积核大小的正方形(绿框),而可变形卷积对应的卷积采样区域为一些蓝框表示的点,这就是可变形卷积与普通卷积的区别。先来一张图感受一下,图3为标准卷积与可变形卷积的卷积示例。

panghuzhenbang的博客 5万+

什么是以太网链路聚合

以太网链路聚合技术通过将多个物理端口捆绑成逻辑端口,可显著提升网络性能。该技术能增加总带宽(各链路带宽之和)、提高可靠性(故障秒级切换)并实现智能负载分担。主要分为手工模式和基于LACP协议的动态模式,后者能检测链路故障更可靠。配置时需确保接口参数一致、模式匹配,适用于核心交换、服务器接入等场景。华为设备通过创建Eth-Trunk接口、指定LACP模式并添加成员接口即可完成部署。这项成熟技术能以低成本解决带宽瓶颈和可靠性问题,是构建高速稳定网络的关键方案。

lai_2020的博客 681

A. Alyona and mex(取mod构造)

https://codeforces.com/problemset/problem/739/A 思路: 大的区间的mex要满足,里面其他小的区间mex要先满足,于是答案取决于最小的区间长度。 至于怎么输出方案,如果暴力n^2超时,其他结合数据结构感觉也不是很好处理。 但是可以构造。每次输出i%最小长度,这样可以保证每个[li​,ri​]的区间都包含[0,ri​−li​] #include<iostream> #include<vector> #include<...

代码笔记本 286

GitHub 新手使用手册

理论说太多容易忘,来实践实践吧。

2501_90226046的博客 1060

Codeforces Round #358 (Div. 2) B. Alyona and Mex

原题链接 B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Someone gave Alyona an array con

L. 503

VS2019手动添加bits/stdc++.h全指南(附解决‘无法打开源文件‘错误)

本文详细介绍了在Visual Studio 2019中手动配置C++万能头文件bits/stdc++.h的完整方法,解决常见的'无法打开源文件'错误。通过分析GCC与MSVC编译器生态差异,提供了纯手动创建和MinGW移植两种可靠方案,并给出详细的步骤、常见错误排查及最佳实践建议,帮助开发者高效配置竞赛开发环境。

weixin_29011395的博客 551

26、遥感图像无监督变化检测方法解析

本文详细解析了遥感图像中的无监督变化检测方法,重点介绍了基于快速模糊 C-均值聚类的无监督变化检测方法(CDFFCM)在滑坡映射中的应用。CDFFCM 方法利用图像结构信息和高斯金字塔技术,提高了检测的准确性,减少了参数数量,并缩短了计算时间。该方法通过与传统方法的对比,展现出在高分辨率遥感图像滑坡检测中的显著优势。此外,文章还探讨了 CDFFCM 的未来发展趋势,包括技术融合、多模态数据应用以及智能化与自动化方向。

game4的博客 153

CodeForces 740C Alyona and mex 简单构造题

C - Alyona and mex Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 740C Description Alyona's mother wants to present

你那么爱笑,家里人知道吗? 944

FPGA实现LVDS接口(1)--IBUFDS原语、OBUFDS原语和IOBUFDS原语的介绍及使用(仿真/源码)

通过本文您会学到:Xinlix的源语IBUFDS、OBUFDS和IOBUFDS是什么?

孤独的单刀 2万+

Codeforces Round #381 (Div. 2) C. Alyona and mex(无语)

题目链接http://codeforces.com/contest/740/problem/C 题意:有一串数字,给你m个区间求每一个区间内不含有的最小的数,输出全部中最小的那个尽量使得这个最小值最大,然后把符合条件的数字串输出,输出任意一种即可 这题只要理解题意差不多就能做出来了,很简单 由于题目要求的mex要最大(mex指着个区间中的数在0~n中缺少的最小的数字例如mex(1...

awow80285的博客 202

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Codeforces Round #381 (Div. 2)C. Alyona and mex

C. Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be

survivorone的博客 404

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces Round #381 (Div. 2)C. Alyona and mex(构造题,好题)

C. Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona's mother wants to present an array

fouzhe的博客 483

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Codeforces Round #381 (Div. 2) C. Alyona and mex

mex代表数组里没出现的最小数,比如  0 1 2 的mex就是3,0 2 3的mex就是1; 给出一个n,和m个n的子区间,求这m个子区间的最小mex最大是多少,并构造一个数组输出。 先看最短的之区间是谁,那么答案就是它的长度,原因嘛,因为它最短所以它的最大mex肯定就是它的长度,然后证明可以找到一个数组可以满足所有的子区间的mex都大于等于这个数就可以了。 如果是m个相同长度的区间,这题

zstu_zy的博客 173

Codeforces Round #381 (Div. 2) C. Alyona and mex(模拟)

C. Alyona and mex time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Alyona’s mother wants to present an array of n non-negative integers to

Prim 947

Codeforces Round #381 (Div. 2) C Alyona and mex (构造)

思路:要求区间的mex最大那么显然就是当这个区间是0,1,2...的时候最大嘛,那么最小的最大mex其实就是区间长度,然后0,1,2,0,1,2那样子的构造就可以了 #include using namespace std; int main() { int n,m; int ans = 1e9; scanf("%d%d",&n,&m); while(m--) { int

围巾的ACM博客 331

Codeforces Round #381 (Div. 2)-C. Alyona and mex

原题链接 C. Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona's mother wants to presen

L. 414

Codeforces Round #381 (Div. 2) C. Alyona and mex

题目大意:要构造一个长度为n的序列,从而使得在由给出的m个区间得到的m个mex值中的最小值 尽可能的大;一个区间的mex值代表不存在于这个区间中的最小的非负整数(有点绕...) 题解思路:解这题有两个突破口;第一个:只从题目给的那两个简单样例也可以发现最终结果的规律,就是结果只跟最短的区间长度有关(或者自己画多几个例子也都会发现的,,虽然我给不出严谨的证明=_=...)。 知道...

weixin_30466953的博客 147

Codeforces Round #381 (Div. 2) C. Alyona and mex(思维)

C. Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona's mother wants to present an array

Marcus-Bao的个人主页 684

Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)

C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she ge...

weixin_30765505的博客 115

Codeforces Round #381 (Div. 1)

A. Alyona and mex 这道题就是使The mex of a set S最大,那么很明显直接找到最小的区间,然后就可以找到最小的The mex of a set S为n,然后对于构造这个序列为循环的(0~n-1),因为这样每个给定的区间的The mex of a set S至少为n。 #include <cstdio> #include <cstring> #include <ios

你真的介意真的在乎真的想要真的渴望的话你一定能够做到 388

Codeforces Round #381C. Alyona and mex

C. Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Alyona's mother wants to present an array

Rain 715

Codeforces Round #381 Div.2

A:Alyona and copybooks 题目大意:已经给了你n本书,你可以选择花a元买一本书,花b元买两本书(严格两本),花c元买三本书(严格三本),让你花最少的钱买x本书使得n+x为4的倍数。 思路:枚举一下买一本书,两本书,三本书的次数,然后统计答案即可。 #include<cmath> #include<cstdio> #include&...

V469584691的博客 296
上一篇: Codeforces Round #381 (Div. 2) A Alyona and copybooks
下一篇: HDU 1593 find a way to escape
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值