贴一份自己的C++:
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
class use {
public:
    use(int start, int end,int index) { this->start = start; this->end = end; this->index = index;}
    int start;
    int end;
    int index;
};
bool compare(use &u1, use &u2)
{
    return u1.start < u2.start;
}
void solution() {
    int n;
    cin >> n;
    vector<use> shetuan;
    for (int i = 0; i < n; ++i)
    {
        int temp1, temp2;
        cin >> temp1 >> temp2;
        shetuan.emplace_back(use(temp1, temp2,i+1));
    }
    sort(shetuan.begin(), shetuan.end(), compare);
    bool isFirst = true;
    bool isCan = true;
    vector<int> res;
    int minTime, maxTime;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i != j)
            {
                if (isFirst)
                {
                    minTime = shetuan[j].start;
                    maxTime = shetuan[j].end;
                    isFirst = false;
                }
                else
                {
                    if (shetuan[j].start < maxTime)
                    {
                        isCan = false;
                        break;
                    }
                    maxTime = shetuan[j].end;
                }
            }
        }
        if (isCan)
            res.emplace_back(shetuan[i].index);
        isFirst = true;
        isCan = true;
    }
    if (res.size() == 0)
        cout << 0;
    else
    {
        cout << res.size()<<endl;
        sort(res.begin(), res.end());
        for (int i = 0; i < res.size(); ++i)
        {
            cout << res[i];
            if (i != res.size() - 1)
                cout << " ";
        }
    }
}
int main() {
   solution() ;
 }