ccfcsp202009-2 風險人群篩查
阿新 • • 發佈:2022-03-05
目錄
題目傳送門
題目傳送門
題目描述
簡單模擬
分析
程式碼
#include<iostream> #include<cstdio> #include<algorithm> #include<vector> using namespace std; typedef pair<int, int> PII; const int N = 1010; vector<PII> people[30]; int n, k, t, xl, yd, xr, yu; int main() { scanf("%d%d%d%d%d%d%d", &n, &k, &t, &xl, &yd, &xr, &yu); int cnt1 = 0, cnt2 = 0; for(int i = 0; i < n; i++) { int tmp = 0, tmpmax = 0; // tmp是計數器,表示連續經過的點數,tmpmax記錄最大段tmp for(int j = 0; j < t; j ++) { int x, y; scanf("%d%d", &x, &y); if( x >= xl && x <= xr && y >= yd && y <= yu) { tmp++; tmpmax = max(tmpmax, tmp); } else { tmp = 0; } // vector[i].push_back({l,r}); } // printf("%dh\n",tmpmax); if(tmpmax > 0) cnt1++; if(tmpmax >= k) cnt2++; } printf("%d\n%d\n", cnt1, cnt2); return 0; }