/*
Time:2019.11.4
Author: Goven
type:偏序问题
err: 1.输入可能(14, 13)
2.房间是对着的,不是一字排开的,所以(2,3) (3,4)是不能同时走的
ref: 类似1065:https://blog.csdn.net/AC_hell/article/details/51416840
*/
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct Node {
int s, e;
};
Node a[205];
bool visit[205];
bool cmp(const Node &x, const Node &y) {
if (x.s != y.s) return x.s < y.s;
return x.e < y.e;
}
int main()
{
int t, n, s, e;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s >> e;
s = (s + 1) / 2;//err2
e = (e + 1) / 2;
a[i].e = max(s, e);//err1
a[i].s = min(s, e);
}
sort(a, a + n, cmp);
memset(visit, 0, sizeof(visit));
int begin, flag, cnt = 0, sum = 0;
while (cnt < n) {
flag = 0; begin = -1;
for (int j = 0; j < n; j++) {
if (visit[j] == false && begin < a[j].s) {
begin = a[j].e;
visit[j] = true;
flag = 1;
}
}
if (flag) sum++;
cnt++;
}
cout << sum * 10 << endl;
}
return 0;
}
网友评论