31C - Schedule - CodeForces Solution


implementation *1700

Please click on ads to support us..

C++ Code:

#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

struct node{
    int first,second,ind;
    
    node(){}
    
    bool operator < (node X)const{
        return first < X.first;
    }
};

int main(){
    int n;
    
    scanf("%d",&n);
    
    node a[n];
    
    for(int i = 0;i < n;++i){
        scanf("%d %d",&a[i].first,&a[i].second);
        a[i].ind = i + 1;
    }
    sort(a,a + n);
    
    int ans = 0;
    vector<int> sol;
    
    for(int i = 0;i < n;++i){
        int cure = 0;
        bool ok = true;
        
        for(int j = 0;j < n;++j){
            if(j != i){
                if(a[j].first >= cure) cure = a[j].second;
                else ok = false;
            }
        }
        
        if(ok){
            ++ans;
            sol.push_back(a[i].ind);
        }
    }
    
    sort(sol.begin(),sol.end());
    printf("%d\n",ans);
    for(int i = 0;i < ans;++i) printf("%d ",sol[i]);
    printf("\n");
    
    return 0;
}
	 	   		 		  		 		 	     		 	 	


Comments

Submit
0 Comments
More Questions

1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract
490C - Hacking Cypher
158B - Taxi
41C - Email address
1373D - Maximum Sum on Even Positions
1574C - Slay the Dragon
621A - Wet Shark and Odd and Even
1395A - Boboniu Likes to Color Balls
1637C - Andrew and Stones
1334B - Middle Class
260C - Balls and Boxes
1554A - Cherry
11B - Jumping Jack
716A - Crazy Computer
644A - Parliament of Berland
1657C - Bracket Sequence Deletion
1657B - XY Sequence
1009A - Game Shopping
1657A - Integer Moves
230B - T-primes
630A - Again Twenty Five
1234D - Distinct Characters Queries
1183A - Nearest Interesting Number
1009E - Intercity Travelling
1637B - MEX and Array
224A - Parallelepiped
964A - Splits
1615A - Closing The Gap