当前位置:网站首页>“蔚来杯“2022牛客暑期多校训练营2 G.[Link with Monotonic Subsequence] 分块构造
“蔚来杯“2022牛客暑期多校训练营2 G.[Link with Monotonic Subsequence] 分块构造
2022-07-26 01:23:00 【HeartFireY】
G. Link with Monotonic Subsequence 构造
题目分析
要求构造一个长度为 n n n的序列,使得序列的 max ( lis ( p ) , lds ( p ) ) \max(\text{lis}(p), \text{lds}(p)) max(lis(p),lds(p))尽可能的小。
狄尔沃斯定理:对偏序集 < A , ≤ > <A,≤> <A,≤>,设A中最长链的长度是 n n n,则将 A A A中元素分成不相交的反链,反链个数至少是 n n n。
那么有 lds ( p ) = c n t ( lis(p) ) \text{lds}(p) = cnt(\text{lis(p)}) lds(p)=cnt(lis(p)),那么显然 max ( lis ( p ) , lds ( p ) ) ≥ max ( k , k n ) ≥ n \max(\text{lis}(p), \text{lds}(p)) \geq \max(k, \frac{k}{n}) \geq \sqrt{n} max(lis(p),lds(p))≥max(k,nk)≥n 。因此直接构造 n \sqrt{n} n个块即可。
Code
#include <bits/stdc++.h>
#pragma gcc optimize(2)
#define int long long
#define endl '\n'
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 7;
inline void solve(){
int n = 0; cin >> n;
int b = ceil(sqrt(n));
while(n > 0){
for(int i = max(1ll, n - b + 1); i <= n; i++) cout << i << " ";
n -= b;
}
cout << endl;
}
signed main(){
ios_base::sync_with_stdio(false), cin.tie(0);
int t = 1; cin >> t;
while(t--) solve();
return 0;
}
边栏推荐
- 4QAM、16QAM 调制与解调仿真电路,观察并分析QAM星座图和误码率曲线【matlab代码】
- Web middleware log analysis script 3.0 (shell script)
- How accurate is the IP address? What are dynamic IP and static IP? The most common method of switching IP
- U++ learning notes ustruct, uenum declaration and function library simple function implementation
- 格式化JS代码,调试JS代码
- Four common simple and effective methods for changing IP addresses
- Should we test the Dao layer?
- 【Go】如何控制协程的最大并发数
- [data mining] differences, advantages and disadvantages between generative model and discriminant model
- Half of the people in the country run in Changsha. Where do half of the people in Changsha run?
猜你喜欢

全国一半人跑长沙,长沙一半人跑哪?

How to obtain the cash flow data of advertising services to help analyze the advertising effect?

谷歌浏览器调试工具使用基础版(一)

Arthas watch command to view the properties of objects in the array

NiO simple example

Linked list related interview questions

Working principle of ZK rollups

2022年最新北京建筑八大员(材料员)模拟考试试题及答案

What if win11 cannot open its own anti-virus software? Win11's built-in anti-virus function cannot be turned on

1.30 升级bin文件添加后缀及文件长度
随机推荐
Working principle of ZK rollups
C语言进阶(一)动态分配内存
记一次自定义 Redis 分布式锁导致的故障
Arthas watch 命令查看数组中对象的属性
NodeJS 基于 Dapr 构建云原生微服务应用,从 0 到 1 快速上手指南
数据库系统原理与应用教程(057)—— MySQL 练习题
Fastjason handles generics
[secsha concept] large and small end
Detailed explanation of rest assured interface testing framework
Linked list related interview questions
点屏注意事项
Tutorial on principles and applications of database system (055) -- MySQL query (XVII): usage of mathematical functions
The gym closes 8000 stores a year. How does the studio that bucks the trend and makes profits open?
[go] III. The simplest restful API server
格式化JS代码,调试JS代码
[Jizhong] July 16, 2022 1432. Oil pipeline
MDK编译过程及ARM编译工具链
FreeBSD bNXT Ethernet driver source code reading record 2:
Mysql_ Note2
健身房一年关店8000家,逆势盈利的工作室是怎么开的?