Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: amongus

Problemset: วันว่างๆ

Language: cpp

Time: 0.019 second

Submitted On: 2026-03-07 15:42:57

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
map<int,int> m;
int main(){

    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x,st,ed;scanf("%d",&x);
        for(int j=1;j<=x;j++){
            scanf("%d %d",&st,&ed);
            m[st]= m[st]+1;
            m[ed] =m[ed] -1;
        }
    }
    int now = 0,check=0;
    for(auto it =m.begin() ; it!=m.end();it++){
        ///printf("+++%d %d\n",it->f,it->s);
        now = now +it->s;
        auto temp = it;
        temp ++;
        if(it->s <0 && now==0 && temp != m.end()){
            check=1;
            printf("%d %d ",it->f  , temp ->f );
        }
    }
    if(check==0)
        printf("-1");


}