fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio (false);
  6. int n, m;
  7. cin>>n>>m;
  8. int min_diff = 100005;
  9. for (int i=0; i<n; i++) {
  10. int l, r;
  11. cin>>l>>r;
  12. min_diff = min (min_diff, r - l + 1);
  13. }
  14. cout<<min_diff<<endl;
  15. for (int i=0; i<n; i++) {
  16. cout<< (i%min_diff)<<" ";
  17. }
  18. cout<<endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 3464KB
stdin
4 2
1 1
3 3
stdout
1
0 0 0 0