// poj 1230 using namespace std; #include int main() { int t, n, k; int lwall[100], rwall[100]; int i, j, p, temp, rmax, count, ans; cin>>t; for (p=0; p>n>>k; /* read input */ for (i=0; i>lwall[i]>>temp>>rwall[i]>>temp; if (lwall[i]>rwall[i]) { temp = lwall[i]; lwall[i] = rwall[i]; rwall[i] = temp; } } ans = 0; j = 0; // column No. /* enumerate each column */ while (j<=100) { count = 0; // number of walls in this column rmax = -1; // the wall No. you want to remove // enumerate each wall for (i=0; i=j) { count ++; if (rmax == -1 || rwall[i]>rwall[rmax]) { rmax = i; } } } /* if current column is unpassable, delete a wall */ if (count>k) { count --; ans ++; /* remove the wall with rightmost endpoint */ lwall[rmax] = -1; rwall[rmax] = -1; } /* go to the next column if the current one is passable */ if (count<=k) { j++; } } cout<