-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1230.cpp
More file actions
62 lines (57 loc) · 1.22 KB
/
1230.cpp
File metadata and controls
62 lines (57 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <vector>
using namespace std;
struct wall_t{
int start;
int end;
bool removed;
};
int cmp ( const void *a , const void *b )
{
return (*(wall_t *)a).end - (*(wall_t *)b).end;
}
int main(){
int testCase;
int t;
int i,j,tmp1,tmp2,right;
wall_t aWall;
int result;
int passCap,wallNum;
wall_t wallList[101];
vector<int> wallProcess;
cin>>testCase;
while((testCase--)>0){
cin>>wallNum>>passCap;
right=0;
for(i=0;i<wallNum;++i){
cin>>aWall.start>>tmp1>>aWall.end>>tmp2;
if(aWall.start>aWall.end){
t=aWall.start;
aWall.start=aWall.end;
aWall.end=t;
}
aWall.removed=false;
if(aWall.end>right){
right=aWall.end;
}
wallList[i]=aWall;
}
//sort by right band
qsort(wallList,wallNum,sizeof(wall_t),cmp);
result=0;
for(i=0;i<=right;++i){
wallProcess.clear();
for(j=0;j<wallNum;++j){
if(!wallList[j].removed && wallList[j].start<=i && i<=wallList[j].end){
wallProcess.push_back(j);
}
}
for(j=passCap;j<wallProcess.size();++j){
wallList[wallProcess[j]].removed=true;
result++;
}
}
cout<<result<<endl;
}
return 0;
}