Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: Test

Problemset: วันว่างๆ

Language: cpp

Time: 0.009 second

Submitted On: 2026-03-04 20:27:17

#include <bits/stdc++.h>
using namespace std;
int mn = 1e9;
int mx =0;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    static int arr[100000];
    int n,m;
    cin >> n;
    for(int ppl=0;ppl<n;ppl++){
        cin >> m;
        for(int i=0;i<m;i++){
            int l,r;
            cin >> l >> r;
            mx = max(mx,max(l,r));
            mn = min(mn,min(l,r));
            arr[l]++;
            arr[r]--;
        }
    }
    for(int i=1; i<=mx; i++){
        arr[i] += arr[i-1];
    }

    int cur = 0;
    int found = 0;
    for(int i = mn; i< mx; i++){
        if(arr[i] == 0){
            int st = i;

            while(i < mx && arr[i] == 0) i++;

            cout << st << " " << i << " ";
            found = 1;
            /*
            if(have == false && i>= mx){
                cout << "-1";
                return 0;
            }
            if(i>= mx) return 0;
            cout << i << " " << i+1 << " ";
            have = true;*/
        }
    }
    if(!found) cout << -1;
    return 0;
}