1 00:12-12:12 2 00:12-12:12 14:00-12:00
1 1
ACM_张开创
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define MAX 100010 struct node { int l,r; }edge[MAX]; int cmp(node s1,node s2) { if(s1.r==s2.r) return s1.l<s2.l; return s1.r<s2.r; } int main() { int n; while(scanf("%d",&n)!=EOF) { int x,y,a,b,c,d; for(int i=0;i<n;i++) { scanf("%d:%d-%d:%d",&a,&b,&c,&d); a=a*60+b; c=c*60+d; if(a>c) swap(a,c); edge[i].l=a,edge[i].r=c; } sort(edge,edge+n,cmp); int cnt=edge[0].r,sum=1; for(int i=1;i<n;i++) { if(edge[i].l>cnt) { sum++; cnt=edge[i].r; } } printf("%d\n",sum); } return 0; }