HBC209386PointsConstructionProblem题解

一沫阳光 算法基础篇 41 0
全网最全C++题库,助您快速提升编程技能!题库丰富多样,涵盖各个领域,让您在练习中不断成长!
Imagine you have an infinite 2D plane with Cartesian coordinate system. Initially, all the integral points are painted as white. You are given two integers n, and m. Please paint exactly n integral points to black such that there are exactly m pairs of points which satisfy the following conditions:

Imagine you have an infinite 2D plane with Cartesian coordinate system. Initially, all the integral points are painted as white. You are given two integers n, and m. Please paint exactly n integral points to black such that there are exactly m pairs of points which satisfy the following conditions: 1. The two points are colored by different colors. 2. the two points are adjacent. We call two integral points (x_1, y_1) (x 1 ​ ,y 1 ​ ) and (x_2, y_2) (x 2 ​ ,y 2 ​ ) being adjacent if and only if |x_1 - x_2| + |y_1 - y_2| = 1 ∣x 1 ​ −x 2 ​ ∣+∣y 1 ​ −y 2 ​ ∣=1. (|v| means the absolute value of v.) 3. The x and y coordinates of all black points are in the range [-10^9, 10^9] [−10 9 ,10 9 ].

HBC209386PointsConstructionProblem题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC209386PointsConstructionProblem题解