CodeForces 740C Alyona and mex

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 740C Alyona and mex相关的知识,希望对你有一定的参考价值。

构造。

比较骚的构造题。肯定可以构造出$min(R-L+1)$,只要$0$ $1$ $2$ $...$ $R-L$ $0$ $1$ $2$ $...$ $R-L$填数字即可,这样任意一段区间都包含了$0$ $1$ $2$ $...$ $R-L$。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0);
void File()
{
    freopen("D:\\in.txt","r",stdin);
    freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
    char c = getchar();
    x = 0;
    while(!isdigit(c)) c = getchar();
    while(isdigit(c))
    {
        x = x * 10 + c - 0;
        c = getchar();
    }
}

int n,m;

int main()
{
    cin>>n>>m; int len=600000;
    for(int i=1;i<=m;i++)
    {
        int L,R; cin>>L>>R;
        len=min(len,R-L+1);
    }

    cout<<len<<endl;
    for(int i=0;i<n;i++)
    {
        cout<<(i+len-1)%len<<" ";
    }
    cout<<endl;
    return 0;
}

 

以上是关于CodeForces 740C Alyona and mex的主要内容,如果未能解决你的问题,请参考以下文章

CodeForces 740A Alyona and copybooks

codeforces 682D Alyona and Strings

Codeforces Round #401 (Div. 2)C. Alyona and Spreadsheet(暴力)

Alyona and towers CodeForces - 739C (线段树)

CodeForces 682D Alyona and Strings

codeforces 682D(Alyona and Strings)