每日一题 第八十二期 CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!)

2024-04-08 1133阅读

C1. Bessie’s Birthday Cake (Easy Version)

time limit per test: 2 seconds

memory limit per test: 256 megabytes

input: standard input

output: standard output

Proof Geometric Construction Can Solve All Love Affairs - manbo-p

This is the easy version of the problem. The only difference between the two versions is the constraint on y y y. In this version y = 0 y = 0 y=0. You can make hacks only if both versions are solved.

Bessie has received a birthday cake from her best friend Elsie, and it came in the form of a regular polygon with n n n sides. The vertices of the cake are numbered from 1 1 1 to n n n clockwise. You and Bessie are going to choose some of those vertices to cut non-intersecting diagonals into the cake. In other words, the endpoints of the diagonals must be part of the chosen vertices.

Bessie would only like to give out pieces of cake which result in a triangle to keep consistency. The size of the pieces doesn’t matter, and the whole cake does not have to be separated into all triangles (other shapes are allowed in the cake, but those will not be counted).

Bessie has already chosen x x x of those vertices that can be used to form diagonals. She wants you to choose no more than y y y other vertices such that the number of triangular pieces of cake she can give out is maximized.

What is the maximum number of triangular pieces of cake Bessie can give out?

Input

The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 4 1 \leq t \leq 10^4 1≤t≤104) — the number of test cases.

The first line of each test case consists of three integers, n n n, x x x, and y y y ( 4 ≤ n ≤ 1 0 9 4 \leq n \leq 10^9 4≤n≤109, 2 ≤ x ≤ min ⁡ ( n , 2 ⋅ 1 0 5 ) 2 \leq x \leq \min(n, 2 \cdot 10^5) 2≤x≤min(n,2⋅105), y = 0 y = 0 y=0) — the number of sides of the polygon, number of vertices Bessie has chosen, and the maximum number of other vertices you can choose.

The second line consists of x x x distinct integers from 1 1 1 to n n n, representing the vertices Bessie has chosen.

It is guaranteed the sum of x x x over all test cases does not exceed 2 ⋅ 1 0 5 2 \cdot 10^5 2⋅105.

Output

For each test case, output a single integer: the maximum number of non-intersecting triangular pieces of cake she can give out.

Example

inputCopy

3

8 4 0

1 6 2 5

8 8 0

1 3 2 5 4 6 7 8

4 2 0

1 3

outputCopy

2

6

2

Note

In test cases 1 1 1, 2 2 2 and 3 3 3, you can get 2 2 2, 6 6 6 and 2 2 2 non-intersecting triangular pieces of cake, respectively. A possible construction is shown in the following pictures:

The green dots represent vertices that can be used, the blue lines represent diagonals that are drawn, and the red numbers represent triangles that are counted.

每日一题 第八十二期 CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!)

AC代码:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pairPII;
const int N=3e5+10;
const int MOD=1e9 + 7;
const int INF=0X3F3F3F3F;
const int dx[]={-1,1,0,0,-1,-1,+1,+1};
const int dy[]={0,0,-1,1,-1,+1,-1,+1};
const int M = 1e6 + 10;
int t ;
int n, x ,y;
int a[N];
int main()
{
	cin >> t;
	while(t --){
		cin >> n >> x >> y;
		for(int i = 1; i 
			cin > a[i];
		}
		sort(a + 1, a + 1 + x);
		a[x + 1] = a[1] + n;
		int ans = x - 2;
		for(int i = 1; i 
			if(a[i + 1] - 2 == a[i]) ans ++;
		}
		cout 
VPS购买请点击我

免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!

目录[+]