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

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 1t104) — 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 4n109, 2 ≤ x ≤ min ⁡ ( n , 2 ⋅ 1 0 5 ) 2 \leq x \leq \min(n, 2 \cdot 10^5) 2xmin(n,2105), 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 2105.

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.

AC代码:

#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<queue>
#include<string>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<iomanip>
#define endl '\n'
using namespace std;typedef long long ll;
typedef pair<int, int>PII;
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 <= x; 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 <= x; i ++){if(a[i + 1] - 2 == a[i]) ans ++;}cout << ans << endl;}return 0;
}

//纯数学

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/601409.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【C++ STL算法】sort 排序

文章目录 【 1. 基本原理 】【 2. sort 的应用 】实例 - sort 函数实现 升序排序和降序排序 函数名用法sort (first, last)基于 快速排序&#xff0c;对容器或普通数组中 [ first, last ) 范围内的元素进行排序&#xff0c;默认进行升序排序&#xff08;从小到大&#xff09;。…

幸运数(蓝桥杯)

该 import java.util.*; public class Main {public static void main(String[] args) {Scanner scannew Scanner(System.in);int cnt0;for(int i1;i<100000000;i) {String si"";int lens.length();if(len%2!0) continue;int sum10; //左边int sum20; //右边fo…

CLIP模型入门

简介 CLIP&#xff08;Contrastive Language-Image Pre-Training&#xff09;是OpenAI在2021年初发布的多模态预训练神经网络模型&#xff0c;用于匹配图像和文本。该模型的关键创新之一是将图像和文本映射到统一的向量空间&#xff0c;通过对比学习的方式进行预训练&#xff…

如何给MySQL数据库的所有表统一加上字段

在开发过程中&#xff0c;有时候慢慢的建了很多数据库表&#xff0c;但是后来发现需要统一增加某些字段的时候&#xff0c;可以通过alter语句 ALTER TABLE 表名 ADD 列名 数据类型;比如我要给t_user表增加gmt_create与gmt_modified字段&#xff0c;用作记录新增记录时间与更新…

基于支持 GPT 的服务的初创公司

Kafkai&#xff1a;多语言长篇内容生成&#xff0c;AI写作的新趋势 介绍 随着生成式预训练 Transformer (GPT) 的出现&#xff0c;技术世界正在见证范式转变。 这种人工智能驱动的创新不仅仅是一种转瞬即逝的趋势&#xff0c;而是一种趋势。 它已成为科技行业的基石&#xff0c…

做海外问卷调查有什么技巧和方法?纯干货讲解

做海外问卷调查无外乎几个步骤&#xff1a;选国家、做人设、测题目、刷题目。每个步骤都有一定的技巧&#xff0c;但是它的技巧成分不是很明显。 国家的选择一般以发达国家为主&#xff0c;国家越发达问卷的数量越多&#xff0c;正常白天做题主流国家选择&#xff1a;新加坡、…

【Java EE】Spring请求如何传递参数详解

文章目录 &#x1f38d;传递单个参数&#x1f334;传递多个参数&#x1f340;传递对象&#x1f384;后端参数重命名&#xff08;后端参数映射&#xff09;&#x1f332;传递数组&#x1f38d;传递集合&#x1f334;传递JSON数据&#x1f338;JSON概念&#x1f338;JSON的语法&a…

2024年阿里云优惠券(代金券)在哪里领取?

阿里云作为国内领先的云计算服务提供商&#xff0c;不仅提供了稳定、高效的云服务&#xff0c;还时常推出各种优惠活动&#xff0c;以此来吸引用户上云。其中&#xff0c;阿里云优惠券就是一种常见的优惠方式。那么&#xff0c;在2024年&#xff0c;我们该如何领取阿里云优惠券…

动态规划:背包问题合集

01背包 定义dp[i][j]&#xff1a;在前i件物品中选出若干件&#xff0c;放入容量为j的背包&#xff0c;能获得的最大价值。 考虑第i件物品拿还是不拿。讨论c[i]与背包容量的关系&#xff1a; &#xff08;1&#xff09;j < c[i] 时&#xff0c;背包容量为j&#xff0c;而第…

基于java+springboot+vue实现的教学辅助系统(文末源码+Lw)23-225

摘 要 互联网发展至今&#xff0c;无论是其理论还是技术都已经成熟&#xff0c;而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播&#xff0c;搭配信息管理工具可以很好地为人们提供服务。针对信息管理混乱&#xff0c;出错率高&#xff0c;信息安全性差&#…

ics-05-攻防世界

题目 点了半天只有设备维护中心能进去 御剑扫一下 找到一个css 没什么用 再点击云平台设备维护中心url发生了变化 设备维护中心http://61.147.171.105:65103/index.php?pageindex试一下php伪协议 php://filter/readconvert.base64-encode/resourceindex.php base64解一下…

LLM-base版本和chat版本的比较

突然想到了这个问题&#xff0c;网上搜集了一些资料&#xff0c;自己也总结一下 首先放一张llama2论文当中的图&#xff0c;可以很直观的看到区别 面试回答版 问题&#xff1a; 大语言模型base版和chat版的区别是什么&#xff1f; 回答&#xff1a; base版本更适合文本补全…