|
|
|
@ -8,9 +8,16 @@ struct Node {
|
|
|
|
|
int st, ed;
|
|
|
|
|
};
|
|
|
|
|
vector<Node> q;
|
|
|
|
|
int res;
|
|
|
|
|
/*
|
|
|
|
|
5
|
|
|
|
|
1 2 3 3 2
|
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
3 2 4 2 3
|
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
3 2 4 2 5 3 1
|
|
|
|
|
*/
|
|
|
|
|
int main() {
|
|
|
|
|
int n;
|
|
|
|
@ -27,9 +34,21 @@ int main() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从左到右枚举,所以,不再需再进行按左端点排序,现在就是按左端点排序完的
|
|
|
|
|
// Q:求一组区间的相交区间个数?如果存在一个相交区间,就多加1个1
|
|
|
|
|
res = q.size();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < q.size(); i++) cout << q[i].st << " " << q[i].ed << endl;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < q.size(); i++)
|
|
|
|
|
for (int j = i + 1; j < q.size(); j++) {
|
|
|
|
|
if (q[i].ed > q[j].st && q[j].ed > q[i].ed) {
|
|
|
|
|
res++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cout << res << endl;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|