Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- for(int i = 0; i < t; i++) {
- int n;
- cin >> n;
- int l, r;
- cin >> l >> r;
- int k = 1;
- if(k < l || k > r)
- cout << 0 << " ";
- else
- cout << k++ << " " ;
- for(int j = 0; j < n - 1; j++) {
- int a, b;
- cin >> a >> b;
- if(k < a || k > b || (a == l && b < r)) {
- cout << 0 << " " ;
- }
- else {
- cout << k++ << " " ;
- }
- l = a;
- r = b;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement