Advertisement
ibragimova_mariam

Untitled

Dec 27th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin >> t;
  9.  
  10. for(int i = 0; i < t; i++) {
  11. int n;
  12. cin >> n;
  13. int l, r;
  14. cin >> l >> r;
  15. int k = 1;
  16. if(k < l || k > r)
  17. cout << 0 << " ";
  18. else
  19. cout << k++ << " " ;
  20.  
  21. for(int j = 0; j < n - 1; j++) {
  22. int a, b;
  23. cin >> a >> b;
  24. if(k < a || k > b || (a == l && b < r)) {
  25. cout << 0 << " " ;
  26. }
  27. else {
  28. cout << k++ << " " ;
  29. }
  30. l = a;
  31. r = b;
  32. }
  33. cout << endl;
  34. }
  35.  
  36.  
  37.  
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement