题目
暂时不写了,有时间再整
解题思路-初
题干废话少了些,大意是给你目标矩阵的左下、右上角,以及居民的记录坐标,判断两点
- 经过——是否存在点在矩阵边上或者内部
- 逗留——是否存在连续的点经过(本题唯一小难点)
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;
}
测试样例
暂时不写