Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: C12

Problemset: วันว่างๆ

Language: cpp

Time: 0.009 second

Submitted On: 2026-03-07 23:43:31

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    
    int mx = 0;
    int mn = INT_MAX;

    int sum[1001] = {0};

    for(int i = 0;i < n;i++){
        int m,u,v;
        cin >> m;
        for(int j = 0;j < m;j++){
            cin >> u >> v;
            mn = min(mn,u);
            mx = max(mx,v);
            sum[u]++;
            sum[v]--;
        }    
    }
    int chill = 0;
    int cnt = 0;
    int pri = 0;

    for(int i = mn;i < mx;i++){
        cnt += sum[i];
        // cout << i << ' ' << cnt << '\n';
        if(cnt == 0){
            if(!chill){
                cout << i << ' ';
                chill = 1;
                pri = 1;
            }
        }
        else{
            if(chill){
                cout << i << ' ';
                chill = 0;
            }
        }
    }

    if(!pri) cout << -1;

    return 0;
}