-
问题链接:风险人群筛查
-
问题分析:模拟法解决。
-
程序说明:n表示居民数量;k表示约束中的连续k个坐标位于矩形内;t表示每个居民的t个时刻;xl,yd,xr,yu表示矩形的左下角和右上角的坐标
-
程序代码:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Reader {
static StringTokenizer token =new StringTokenizer("");
static BufferedReader reader =new BufferedReader (new InputStreamReader(System.in)) ;
static String nextLine() throws IOException {
return reader.readLine() ;
}
static String next() throws IOException {
while(!token.hasMoreTokens()) {
token =new StringTokenizer(reader.readLine()) ;
}
return token.nextToken() ;
}
static int nextInt() throws IOException {
return Integer.parseInt(next()) ;
}
static double nextDouble() throws IOException {
return Double.parseDouble(next()) ;
}
}
public class Main {
public static void main(String[] args) throws IOException {
int n = Reader.nextInt();
int k = Reader.nextInt();
int t = Reader.nextInt();
int xl = Reader.nextInt();
int yd = Reader.nextInt();
int xr = Reader.nextInt();
int yu = Reader.nextInt();
int passer = 0;//记录经过的人数
int stayer = 0;//记录逗留的人数
for(int i=0;i<n;i++) {
boolean flag1 = false;
boolean flag2 = false;
int count = 0;
for(int j=0;j<t;j++) {
int x = Reader.nextInt();
int y = Reader.nextInt();
if((x>=xl&&x<=xr)&&(y>=yd&&y<=yu)) {
flag1 = true;
count++;
}else{
count = 0;
}
if(count==k) {
flag2 = true;
}
}
if(flag1) {
passer++;
}
if(flag2) {
stayer++;
}
}
System.out.println(passer);
System.out.println(stayer);
}
}