题意:要求构造一个1-n的排列,使得它的LIS+LDS最小

n<=1e5

思路:一个百度之星时候从LYY处听来的结论:1-n随机排列的LIS期望是根号级别的

考虑将LIS与LDS都构造成根号级别

分块,块内增(减),块间减(增)

 #include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair
#define N 110000
#define MOD 1000000007
#define eps 1e-8
#define pi acos(-1) int a[N]; int read()
{
int v=,f=;
char c=getchar();
while(c<||<c) {if(c=='-') f=-; c=getchar();}
while(<=c&&c<=) v=(v<<)+v+v+c-,c=getchar();
return v*f;
} void swap(int &x,int &y)
{
int t=x;x=y;y=t;
} int main()
{
//freopen("1.in","r",stdin);
//freopen("1.out","w",stdout);
int n;
scanf("%d",&n);
int block=sqrt(n);
int m=n/block;
int now=n;
int s=;
int st=n-block+;
for(int i=;i<=m;i++)
{
for(int j=;j<=block;j++) a[++s]=st++;
st=st-*block;
}
if(n%block)
{
st=;
for(int i=;i<=n%block;i++) a[++s]=st++;
} for(int i=;i<=n;i++) printf("%d ",a[i]);
return ;
}

【CF1017C】The Phone Number(构造)的更多相关文章

  1. js Number方法总结

    Number构造属性 Number.EPSILON // 两个可表示(representable)数之间的最小间隔. Number.MAX_SAFE_INTEGER // JavaScript 中最大 ...

  2. javascript中的Function和Object

    写的很好,理解了很多,特此转发记录 转自:http://blog.csdn.net/tom_221x/archive/2010/02/22/5316675.aspx 在JavaScript中所有的对象 ...

  3. 到底instanceof是啥?

    对Js有一定了解的盆友肯定都知道instanceof 并且还很常用,比如说用[1, 2, 3] instanceof Array 来判断是否是数组.所以我们可能会简单的以为他就是一个用来判断typeo ...

  4. 记一次SQL联合查询注入工具的编写

    这是一个ASP网站的简单SQL注入检测和利用的工具,主要的功能是简单的检测出SQL注入漏洞,可以使用该id存在的SQL注入来获取数据库中的网站管理员的表名和字段名,猜解数据库中该表的字段数,最后通过联 ...

  5. codeforces div2 C题思路训练【C题好难,我好菜】

    1017C The Phone Number: 构造数列使得LIS和LDS的和最小,定理已知LIS=L,LDS=n/L的向上取整,根据样例可以得到设置L=根号n,构造方法如样例 截断法构造,不用考虑边 ...

  6. Halcon例程detect_indent_fft学习

    ************************************************************************************************ *** ...

  7. 2017 ACM Amman Collegiate Programming Contest 题解

    [题目链接] A - Watching TV 模拟.统计一下哪个数字最多即可. #include <bits/stdc++.h> using namespace std; const in ...

  8. python3爬取咪咕音乐榜信息(附源代码)

    参照上一篇爬虫小猪短租的思路https://www.cnblogs.com/aby321/p/9946831.html,继续熟悉基础爬虫方法,本次爬取的是咪咕音乐的排名 咪咕音乐榜首页http://m ...

  9. python3通过Beautif和XPath分别爬取“小猪短租-北京”租房信息,并对比时间效率(附源代码)

    爬虫思路分析: 1. 观察小猪短租(北京)的网页 首页:http://www.xiaozhu.com/?utm_source=baidu&utm_medium=cpc&utm_term ...

  10. angular关于依赖注入

    <html> <head> <title>Angular JS Forms</title> </head> <body> < ...

随机推荐

  1. python报错UnicodeDecodeError:

    Python 里面的编码和解码也就是 unicode 和 str 这两种形式的相互转化.编码是 unicode -> str,相反的,解码就 是 str -> unicode.剩下的问题就 ...

  2. 12_1_Annotation注解

    12_1_Annotation注解 1. 什么是注解 Annotation是从JDK5.0开始引入的新技术. Annotation的作用: 不是程序本身,可以对程序作出解释.可以被其他程序(比如,编译 ...

  3. java 第11次作业:你能看懂就说明你理解了——this关键字

    this 代表当前对象

  4. 代码方式使用AutoLayout (NSLayoutConstraint + Masonry)

    随着iPhone6/6+设备的上市,如何让手头上的APP适配多种机型多种屏幕尺寸变得尤为迫切和必要.(包括:iPhone4/4s,iPhone5/5s,iPhone6/6s,iPhone 6p/6ps ...

  5. MySQL数据库主从切换脚本自动化

    MySQL数据库主从切换脚本自动化 本文转载自:https://blog.csdn.net/weixin_36135773/article/details/79514507 在一些实际环境中,如何实现 ...

  6. Golang ioutil读写文件测试

    运用 ioutil.ReadFile .ioutil.WriteFile package main import ( "io/ioutil" "log" &qu ...

  7. 拓展jQuery的serialize(),将form表单转化为json对象

    jQuery 的 serialize() 方法经常会报 Uncaught TypeError: JSON.serializeObject is not a function 的错误, 原装的方法真的一 ...

  8. setup/hold 分析

    分析说明:D2:目的寄存器:D1:源寄存器: edge2:下一个时钟上升沿:edge1:当前时钟上升沿:edge0:当前时钟上升沿的前一个时钟沿:如下图: 建立时间:触发器D2(数据要到达目的的地方) ...

  9. 求数组中两两相加等于20的组合(Python实现)

    题目 求数组中两两相加等于20的组合. 例:给定一个数组[1, 7, 17, 2, 6, 3, 14],这个数组中满足条件的有两对:17+3=20, 6+14=20. 解析 分为两个步骤: 先采用堆排 ...

  10. meteor 检测运行环境,手机或者桌面

    meteor add mystor:device-detection Meteor.Device.isPhone() https://atmospherejs.com/mystor/device-de ...