http://codeforces.com/contest/740/problem/C

构造思维题。

第一直觉就是区间长度+1的最小值就是答案。

然而不知道怎么去构造这个序列、

其实就是每个区间,都要包含0、1、2、3、...ans - 1即可。

所以,只要不断0、1、2、3、4、...ans - 1、0、1、2、3、....这样放即可。

因为最小的区间长度是ans - 1,那么选出来的区间只能比这个大,那么拿到绝对包含了0、1、2、3、4...ans - 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e5 + ;
struct node {
int L, R;
int val;
bool operator < (const struct node & rhs) const {
if (val != rhs.val) return val < rhs.val;
else if (R != rhs.R) return R > rhs.R;
else return L > rhs.L;
}
} q[maxn];
int a[maxn];
int vis[maxn];
int n, m; void work() {
IOS;
cin >> n >> m;
int ans = inf;
for (int i = ; i <= m; ++i) {
cin >> q[i].L >> q[i].R;
q[i].val = q[i].R - q[i].L + ;
ans = min(ans, q[i].val);
}
cout << ans << endl;
int to = ;
for (int i = ; i <= n; ++i) {
cout << to << " ";
to++;
to %= ans;
}
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}

C. Alyona and mex的更多相关文章

  1. 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 i ...

  2. Codeforces 740C. Alyona and mex 思路模拟

    C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

  3. Codeforces Round #381 (Div. 1) A. Alyona and mex 构造

    A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...

  4. 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 in ...

  5. CodeForces 682B Alyona and Mex (排序+离散化)

    Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...

  6. Alyona and mex

    Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

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

    B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...

  8. CF | Alyona and Mex

    Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyon ...

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

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

  10. B - Alyona and Mex

    Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one oper ...

随机推荐

  1. 1250太小了 mysql 并发

    SHOW VARIABLES LIKE '%connection%'; character_set_connection utf8mb4collation_connection utf8mb4_gen ...

  2. 深入解析Hibernate核心接口

    Hibernate有很多值得学习的地方,这里我们主要介绍Hibernate核心接口,包括介绍SessionFactory接口.Query和Criteria接口等方面. Session 接口对于Hibe ...

  3. 在C++中使用Libmd5计算字符串或文件的MD5值

    CppMD5Demo.cpp #include <iostream> #include <fstream> #include <chrono> #include & ...

  4. css3某些特性

    在下列情况下,建议使用opacity属性而不是rgba()函数 1.实现多种颜色(元素)的半透明效果.使用opacity属性,不仅背景颜色,就连文本颜色.边框颜色都会变透明. 2.在不知道颜色的情况下 ...

  5. 学习html5 中的canvas(一)

    1.canvas画直线 <!doctype html> <html> <head> <meta charset="UTF-8"> & ...

  6. vi编辑器设置行号可见

    vi 设置行号 需要切换到命令模式下,输入set number :set number 按下回车即可

  7. Oracle:datafile删除后,重启server报ORA-01110

    模拟实验: 创建一个表空间后,直接把数据文件删除了:然后重启server. 1. create tablespace w56 datafile '/u01/app/oracle/product/10. ...

  8. GCD的使用(1)使用GCD保护property

    作为一个iOS开发者,必须要熟练使用GCD,本文是站在实际应用的角度总结GCD的用法之一: 使用barrier保护property.在多线程环境下,如果有多个线程要执行同一份代码,那么有时会出现问题, ...

  9. liunx操作系统安装<一>

    一:磁盘分区类型(1)主分区(最多四个主分区,比如window系统的C盘,D盘)(2)扩展分区,逻辑分区(为了能让磁盘多分出几个区域而存在)(3)交换分区(虚拟内存,当物理内存不足时候,作为应急存在)

  10. spark运行原理

    一.Spark专业术语定义 二. Spark的任务提交机制 一.Spark专业术语定义 从以下十五个方面描述spark概念. 1  application: spark应用程序 2  Driver:驱 ...