CCF 202009-2 风险人群筛查 100分 46ms

返回试题目录

题目

暂时不写了,有时间再整

解题思路-初

题干废话少了些,大意是给你目标矩阵的左下、右上角,以及居民的记录坐标,判断两点

  1. 经过——是否存在点在矩阵边上或者内部
  2. 逗留——是否存在连续的点经过(本题唯一小难点)

AC代码c++11

在这里插入图片描述

//
//  main.cpp
//  ccf202009-2_start
//
//  Created by tyx on 2020/10/10.
//

#include <iostream>
#include <vector>
#include <utility>
using namespace::std;

//
//struct coordinate{
//    int x;
//    int y;
//};

vector<vector<pair<int, int > > > person;

int n,k,t,xa,xb,ya,yb,sum1,sum2;

int main() {
    // insert code here...
    //std::cout << "Hello, World!\n";
    cin>>n>>k>>t>>xa>>ya>>xb>>yb;
    for (int i = 0; i < n; i++) {
      //  vector<pair<int,int>> direction;
        bool ans1 = 0;
        int ans2 = 0;
        int temp_max = 0;
        for (int j = 0; j < t; j++) {
            int x,y;
            cin>>x>>y;
            if(x<=xb&&x>=xa&&y>=ya&&y<=yb)
            {
                ans1 = 1;
                ans2++;
                
            }
            else{
                if(temp_max <= ans2) temp_max = ans2;
                //temp_max = (temp_max > ans2 ? temp_max : ans2);
                ans2 = 0;
            }
            //cout<<temp_max<<endl;
            //pair<int, int> p1(x,y);
            //direction.push_back(p1);
        }
        if(ans1) sum1++;
        //int temp = (temp_max > ans2 ? temp_max : ans2);
        if(temp_max <= ans2) temp_max = ans2;
        if(temp_max >= k) sum2++;
        //person.push_back(direction);
        //cout<<endl;
    }
    cout<<sum1<<endl;
    cout<<sum2<<endl;
    return 0;
}

测试样例

暂时不写

解题途中遇到的问题

解题思路-反思

修改后代码

python代码

python代码写完后感受

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值