题目描述 参考 博文链接 代码 #include <iostream> #include <algorithm> #include <vector> #include <cctype> using namespace std; int n, k, t, a, b, c, d; bool inArea(int x, int y) { if (a <= x && x <= c && b <= y && y <= d) return true; return false; } int ans[2]; int main() { cin >> n >> k >> t >> a >> b >> c >> d; int x, y; for (int i = 0; i < n; i++) { int cnt = 0, maxCnt = 0; //当前连续在风险区域的时间, 最高连续时间 for (int j = 0; j < t; j++) { cin >> x >> y; cnt = (inArea(x, y)) ? (cnt + 1) : 0; if (cnt > maxCnt) maxCnt = cnt; } if (maxCnt > 0) ans[0]++; if (maxCnt >= k) ans[1]++; } cout << ans[0] << endl << ans[1] << endl; return 0; }