fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int t;
  5. cin>>t;
  6. while(t--){
  7. long int n,mn=INT_MAX,mx=INT_MIN,l,r,sp;
  8. cin>>n;
  9. // vector <long int> l(n,0),r(n,0),sp(n,0);
  10. int i;
  11. vector <pair <long int,pair <long int,long int> > > v;
  12.  
  13. for(i=0;i<n;i++){
  14. cin>>l>>r>>sp;
  15. v.push_back(make_pair(sp,make_pair(l,r)));
  16. }
  17. sort(v.begin(),v.end());
  18. for(i=0;i<n;i++){
  19. if((i+2)<n && v[i].first==v[i+1].first && v[i].first==v[i+2].first){
  20. mn=max(v[i].second.first,v[i+1].second.first);
  21. mx=min(v[i].second.second,v[i+1].second.second);
  22. if((v[i+2].second.first>=mn && v[i+2].second.first<=mx) || (v[i+2].second.second>=mn && v[i+2].second.second<=mx)){
  23. cout<<"NO"<<endl;
  24. break;
  25. }
  26. }
  27. }
  28. if(i==n){
  29. cout<<"YES"<<endl;
  30. }
  31. }
  32. return 0;
  33. }
Time limit exceeded #stdin #stdout 5s 4735484KB
stdin
Standard input is empty
stdout
Standard output is empty