1 /*解题思路:
 2 开启和关闭为一次。
 3 贪心,右端端点升序排序后选择即可*/
 4 
 5 
 6 #include<stdio.h>
 7 #include<stdlib.h>
 8 #include<string.h>
 9 
10 struct P {
11     int s;
12     int e;
13 }P[110];
14 
15 int cmp(const void *a,const void *b) {
16     struct P * c = (struct P *)a;
17     struct P * d = (struct P *)b;
18     return c -> e > d -> e ? 1 : -1;
19 }
20 
21 int main( ) {
22     int n, s1, s2, h1, h2, m1, m2, t ,i, j;
23     int flag, ans;
24     while(scanf("%d", &n) != EOF) {
25         for(i = 0; i < n; i ++) {
26             scanf("%d%*c%d%*c%d%*c%d", &h1, &m1, &h2, &m2);
27             s1 = h1 * 60 + m1;
28             s2 = h2 * 60 + m2;
29             if(s1>s2) {
30                 t = s1;
31                 s1 = s2;
32                 s2 = t;
33             }
34             P[i].s = s1,P[i].e = s2;
35         }
36         qsort(P, n, sizeof(P[0]),cmp);
37         flag = P[0].e;
38         ans = 1;
39         for(j = 1; j < n; j ++) {
40             if(P[j].s > flag) {
41                 flag = P[j]. e;
42                 ans ++;
43             }
44         }
45         printf("%d\n", ans);
46     }
47     return 0;
48 }