CSP 202009

CSP 202009-1

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n,X,Y,x,y;
struct node{
    int dis,id;
    bool operator < (const node u){
        if(dis!=u.dis)return dis<u.dis;
        else return id<u.id;
    }
}a[210];
int main(){
    scanf("%d%d%d",&n,&X,&Y);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x,&y);
        a[i].dis=(x-X)*(x-X)+(y-Y)*(y-Y);
        a[i].id=i;
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=3;i++)printf("%d\n",a[i].id);
    return 0;
}

 

CSP 202009-2

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n,k,t,xl,xr,yd,yu;
int ans1,ans2;
bool in(int x,int y){
    if(x<=xr && x>=xl && y<=yu && y>=yd){
        return 1;
    }
    return 0;
}
int main(){
    scanf("%d%d%d%d%d%d%d",&n,&k,&t,&xl,&yd,&xr,&yu);
    for(int i=1;i<=n;i++){
        int cnt=0,x,y,flag1=0,flag2=0;
        for(int j=1;j<=t;j++){
            scanf("%d%d",&x,&y);
            if(in(x,y)){
                flag1=1;
                cnt++;
            }
            else cnt=0;
            if(cnt>=k){
                flag2=1;
            }
        }
        ans1+=flag1;
        ans2+=flag2;
    }
    printf("%d\n%d\n",ans1,ans2);
    return 0;
}

 

posted @ 2021-03-07 14:37  Echo宝贝儿  阅读(88)  评论(0编辑  收藏  举报