CF2195H.Codeforces Heuristic Contest 001
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There is a grid of 3n×3n points, consisting of all integer points (x,y) such that 1≤x,y≤3n.
Find a largest set of triangles satisfying the following conditions:
- Each triangle has its vertices on exactly three points on the grid.
- Each triangle has an area of exactly 21. Note that they do not have to be right triangles.
- No two triangles share a common intersection point, including their vertices.
If there exist multiple largest such sets of triangles, you may output any of them.
存在一个 3n×3n 的点阵,由所有满足 1≤x,y≤3n 的整数点 (x,y) 构成。
请找出满足以下条件的最大三角形集合:
- 每个三角形的三个顶点均取自该点阵中的三个点;
- 每个三角形的面积恰好为 21(它们不一定是直角三角形);
- 任意两个三角形互不相交(包括顶点在内)。
若存在多个满足上述条件的最大三角形集合,输出其中任意一个即可。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤30). The description of the test cases follows.
The only line of each test case contains a single integer n (1≤n≤166).
It is guaranteed that the sum of n2 over all test cases does not exceed 1662.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤30)。随后是各测试用例的描述。
每个测试用例仅有一行,包含一个整数 n(1≤n≤166)。
保证所有测试用例的 n2 之和不超过 1662。
输出格式
Output the maximum size m of the set of triangles on one line (0≤m≤3n2).
Then, output m lines in the following format:
- xi,1yi,1xi,2yi,2xi,3yi,3: The vertices of the i-th triangle are (xi,1,yi,1), (xi,2,yi,2), (xi,3,yi,3).
You may output the vertices of one triangle in any order (clockwise or counterclockwise).
Your output will be accepted if it satisfies all conditions and the maximum size given is correct.
输出位于同一条直线上的三角形集合的最大大小 m(0≤m≤3n2)。
然后,输出 m 行,格式如下:
- xi,1yi,1xi,2yi,2xi,3yi,3:第 i 个三角形的三个顶点分别为 (xi,1,yi,1)、(xi,2,yi,2)、(xi,3,yi,3)。
每个三角形的三个顶点顺序可任意(顺时针或逆时针均可)。
只要您的输出满足所有条件,且所给出的最大大小 m 正确,即视为可接受。
输入输出样例
输入#1
2 1 2
输出#1
2 1 1 1 2 2 1 2 3 3 2 3 3 12 1 1 1 2 2 1 2 2 3 2 3 1 1 3 1 4 2 3 2 4 3 4 3 3 1 5 1 6 2 5 2 6 3 6 3 5 4 1 4 2 5 1 5 2 6 2 6 1 4 3 4 4 5 3 5 4 6 4 6 3 4 5 4 6 5 5 5 6 6 6 6 5
说明/提示
In the first test case, the example output has 2 triangles as shown in the following image:

In the second test case, the example output has 12 triangles as shown in the image on the left:


As the triangles are not required to be right triangles, the set of triangles shown in the image on the right will also be considered valid.
在第一个测试用例中,示例输出包含 2 个三角形,如下图所示:

在第二个测试用例中,示例输出包含 12 个三角形,如左侧图片所示:


由于题目不要求三角形必须为直角三角形,因此右侧图片中所示的三角形集合也被视为有效。
输入解题思路,AI测评打分。不知道怎么写?