当前位置:网站首页>(Niuke multi School II) G-LINK with monotonic subsequence (construction question)
(Niuke multi School II) G-LINK with monotonic subsequence (construction question)
2022-07-25 05:45:00 【AC__ dream】
subject :
The sample input :
3
1
2
3Sample output :
1
1 2
1 3 2The question : Given a n, Then output a n The whole arrangement p Make it max(lis(p),lds(p)) Minimum .
analysis :
I found the rule of this problem by typing a table , That is to say For a length of n The whole arrangement , that max(lis(p),lds(p)) The minimum value of is sqrt(n) Take the whole of , This is right for some n I got it by trial , Then we try to construct and find that we can do it first n The number is divided into blocks from small to large , The size of each piece is sqrt(n) Take the whole of , Then we can directly output the numbers in a block continuously , First output the block with large number in the block , For example, the length is 9 The whole arrangement , We export it directly 7,8,9,4,5,6,1,2,3
The skill of this kind of question is to find the rule by typing the table first , Then try to construct according to the law
Here is the code :
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<vector>
using namespace std;
const int N=1e6+10;
vector<int>p[N];
int main()
{
int T;
cin>>T;
while(T--)
{
int n;
scanf("%d",&n);
int t=(int)sqrt(n-1)+1;
int cnt=1,tt=1;
p[1].clear();
for(int i=1;i<=n;i++)
{
if(cnt>t) cnt=1,p[++tt].clear();
cnt++;
p[tt].push_back(i);
}
for(int i=tt;i>=1;i--)
for(int j=0;j<p[i].size();j++)
printf("%d ",p[i][j]);
puts("");
}
return 0;
}
边栏推荐
- LCP plug-in creates peer-to-peer 802.1ad interface
- Msys2 common configuration
- HTB-Optimum
- Microservice - hystrix fuse
- Concepts of phase velocity and phase in transmission line theory
- 聊聊 Redis 是如何进行请求处理
- CSDN编程挑战赛之数组编程问题
- Introduction summary of using unirx in unity
- y76.第四章 Prometheus大厂监控体系及实战 -- prometheus进阶(七)
- How to start if you want to be a product manager?
猜你喜欢

Airserver 7.3.0 Chinese version mobile device wireless transmission computer screen tool

C编程 --“最大子数组的和” 的动态规划的解法

同条网线电脑正常上网,手机连接wifi成功,但是无法访问互联网

Leetcode 204. count prime numbers (wonderful)

线性代数(三)

10、渲染基础

Leetcode 237. 删除链表中的节点

The selection reference of Junzheng T41, T40 and T31 versions are all here

Mechanism and principle of multihead attention and masked attention

idea常用10个快捷键
随机推荐
systemVerilog中automatic用法
ERA5数据集说明
PHP warehouse inventory management system source code WMS source code
Leetcode 237. delete nodes in the linked list
Ffmpeg notes (I) fundamentals of audio and video
R language ggpubr package ggarrange function combines multiple images and annotates_ Figure add annotation, annotation, annotation information for the combined image, and use the right parameter to ad
Microservice configuration center Nacos
Promise implementation
Softing pngate series gateway: integrate PROFIBUS bus into PROFINET network
The computer accesses the Internet normally with the same network cable, and the mobile phone connects to WiFi successfully, but it cannot access the Internet
leetcode/ 前 n 个数字二进制中 1 的个数
Array programming problem of CSDN programming challenge
Unity接入ChartAndGraph图表插件
Realsense d435i depth map optimization_ High precision mode
SystemVerilog中$write与$display区别
C Programming -- the solution of dynamic programming of "the sum of the largest subarray"
出于数据安全考虑,荷兰教育部要求学校暂停使用 Chrome 浏览器
The u-collapse component of uniapp mobile uview is highly init
Why is it that all the games are pseudorandom and can't make true random?
R language uses data.table function to create data.table data (use: operator to create continuous numeric vector)