题解:AT_arc222_a [ARC222A] Colorful Intervals
题意
构造一个正整数序列
思路
考虑任意一个区间
尝试用尽量小的最大值来构造序列,即让
为什么这样构造是合法的,在循环序列
时间复杂度
代码
#include <bits/stdc++.h>
using namespace std;
int t,n,m,l,r;
int main() {
ios::sync_with_stdio(false);
cin>>t;
while (t--) {
cin>>n>>m;
int K=0;
for (int i=0; i<m; ++i) {
cin>>l>>r;
K=max(K,r-l+1);
}
for (int i=1; i<=n; ++i) {
cout<<(i-1)%K+1<<(i==n?'\n':' ');
}
}
return 0;
}