#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; #define CLR(x,y) memset((x),(y),sizeof((x))) #define FOR(x,y,z) for(int (x)=(y);(x)<(z);++(x)) #define FORD(x,y,z) for(int (x)=(y);(x)>=(z);--(x)) #define FOR2(x,y,z) for((x)=(y);(x)<(z);++(x)) #define FORD2(x,y,z) for((x)=(y);(x)>=(z);--(x)) struct P{ int s,e; bool operator < (const P & a)const { return e < a.e || (e == a.e && s > a.s); } }p[30]; int main(){ //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int cntcase; scanf("%d",&cntcase); while (cntcase--){ int cnt = 0; while(scanf("%d%d",&p[cnt].s,&p[cnt].e) && (p[cnt].s || p[cnt].e)) ++cnt; sort(p,p+cnt); int res = 1; P pre = p[0]; for(int i = 1; i < cnt;i++){ if(p[i].s >= pre.e){ ++res; pre = p[i]; } } printf("%d\n",res); } return 0; } |
[2016-03-07][ UVALive?6606?Meeting?Room?Arrangement??]
原文:http://www.cnblogs.com/qhy285571052/p/5250158.html