CF Round#381(div2)C 思维+构造

来源:互联网 发布:椭圆拟合编程 编辑:程序博客网 时间:2024/05/22 02:23

题意:

题目链接:http://codeforces.com/contest/740/problem/C
构造一串序列,满足给出的区间[L,R]中没有出现的最小数字最大,给出这个值,并且输出任意一组构造解。


思路:

YY题,可以发现最小的就是最短区间的长度,至于构造就直接按照循环节输出即可。


代码:

#include <bits/stdc++.h>using namespace std;const int MAXN = 1e5 + 10;const int INF = 0x3f3f3f3f;int a[MAXN];int main() {   // freopen("in.txt", "r", stdin);    int n, m, t = INF;    scanf("%d%d", &n, &m);    for (int i = 1; i <= m; i++) {        int l, r;        scanf("%d%d", &l, &r);        t = min(t , r - l + 1);    }    printf("%d\n", t);    for (int i = 0; i < n; i++) {        printf("%d%c", i % t, i == n - 1 ? '\n' : ' ');    }    return 0;}