202009-2 风险人群筛查

简单题,就是不明白,为什么相同的代码在不同时间却答案不同

#include<bits/stdc++.h>
using namespace std;
int xl,yd,xr,yu;
bool in(int x,int y)
{
    return xl<=x && x<=xr && yd<=y && y<=yu;
}
int main()
{
    int ans1=0,ans2=0;
    int n,k,t;
    cin>>n>>k>>t>>xl>>yd>>xr>>yu;
    while(n--){
        bool flag1=false;
        bool flag2=false;
        int x,y;
        int count=0;
        for (int i = 0; i < t; i++){
            cin>>x>>y;
            if(in(x,y)){
                count++;
                flag1=true;
            }
            if(count>=k){
                flag2=true;
            }
            if(!in(x,y)){
                count=0;
            }
        }
        if(flag1) ans1++;
        if(flag2) ans2++;
    }
    cout<<ans1<<endl<<ans2;
    return 0;
}

 

posted @ 2021-03-27 20:37  南理工学渣  阅读(77)  评论(0)    收藏  举报