2025.1.14——1200

news/2025/1/15 21:06:09/文章来源:https://www.cnblogs.com/jkkk/p/18673711

2025.1.14——1200


Q1. 1200

You have \(n\) sticks, numbered from \(1\) to \(n\). The length of the \(i\)-th stick is \(2^{a_i}\).

You want to choose exactly \(3\) sticks out of the given \(n\) sticks, and form a non-degenerate triangle out of them, using the sticks as the sides of the triangle. A triangle is called non-degenerate if its area is strictly greater than \(0\).

You have to calculate the number of ways to choose exactly \(3\) sticks so that a triangle can be formed out of them. Note that the order of choosing sticks does not matter (for example, choosing the \(1\)-st, \(2\)-nd and \(4\)-th stick is the same as choosing the \(2\)-nd, \(4\)-th and \(1\)-st stick).
Input

  • the first line contains one integer \(n\) (\(1 \le n \le 3 \cdot 10^5\));
  • the second line contains \(n\) integers \(a_1, a_2, \dots, a_n\) (\(0 \le a_i \le n\)).

Q2. 1200

Masha and Olya have an important team olympiad coming up soon. In honor of this, Masha, for warm-up, suggested playing a game with Olya:

There is an array \(a\) of size \(n\). Masha goes first, and the players take turns. Each move is described by the following sequence of actions:

\(\bullet\) If the size of the array is \(1\), the game ends.

\(\bullet\) The player who is currently playing chooses two different indices \(i\), \(j\) (\(1 \le i, j \le |a|\)), and performs the following operation — removes \(a_i\) and \(a_j\) from the array and adds to the array a number equal to \(\lfloor \frac{a_i + a_j}{2} \rfloor \cdot 2\). In other words, first divides the sum of the numbers \(a_i\), \(a_j\) by \(2\) rounding down, and then multiplies the result by \(2\).

Masha aims to maximize the final number, while Olya aims to minimize it.

Masha and Olya decided to play on each non-empty prefix of the initial array \(a\), and asked for your help.

For each \(k = 1, 2, \ldots, n\), answer the following question. Let only the first \(k\) elements of the array \(a\) be present in the game, with indices \(1, 2, \ldots, k\) respectively. What number will remain at the end with optimal play by both players?
Input

The first line of each test case contains a single integer \(n\) (\(1 \le n \le 10^5\)) — the size of the array.

The second line contains \(n\) integers \(a_1,a_2, \ldots,a_n\) (\(1 \leq a_i \leq 10^9\)) — the array on which Masha and Olya play.


Q3. 1200

Vlad found a string \(s\) consisting of \(n\) lowercase Latin letters, and he wants to make it as short as possible.

To do this, he can remove any pair of adjacent characters from \(s\) any number of times, provided they are different. For example, if \(s\)=racoon, then by removing one pair of characters he can obtain the strings coon, roon, raon, and raco, but he cannot obtain racn (because the removed letters were the same) or rcon (because the removed letters were not adjacent).

What is the minimum length Vlad can achieve by applying any number of deletions?
Input

The first line of each test case contains a single integer \(n\) (\(1 \le n \le 2 \cdot 10^5\)) — the length of the string \(s\).

The second line of each test case contains the string \(s\) consisting of \(n\) lowercase Latin letters.


Q4. 1200

Monocarp tries to get home from work. He is currently at the point \(O = (0, 0)\) of a two-dimensional plane; his house is at the point \(P = (P_x, P_y)\).

Unfortunately, it is late in the evening, so it is very dark. Monocarp is afraid of the darkness. He would like to go home along a path illuminated by something.

Thankfully, there are two lanterns, located in the points \(A = (A_x, A_y)\) and \(B = (B_x, B_y)\). You can choose any non-negative number \(w\) and set the power of both lanterns to \(w\). If a lantern's power is set to \(w\), it illuminates a circle of radius \(w\) centered at the lantern location (including the borders of the circle).

You have to choose the minimum non-negative value \(w\) for the power of the lanterns in such a way that there is a path from the point \(O\) to the point \(P\) which is completely illuminated. You may assume that the lanterns don't interfere with Monocarp's movement.

The picture for the first two test cases


------------------------独自思考分割线------------------------

  • 结论+博弈+结论+结论


A1.

  1. 发现贡献可以缩小选择范围:只有等腰或等边三角形。
  2. 组合一下计算方案数。

A2.

  1. 本质就是发现损失的原因和决策。
  2. 根据奇偶性博弈一下发现损失和奇数的个数有一定关系。

A3.

  1. 思考最后答案的形态是同一个字母。
  2. 充分性策略:考虑最多的那个字母,尽量去消去它,而且在其他字母存在的时候一定可以消去它。
  3. 未消完剩下的就是最优答案,消完再讨论下奇偶决定答案0/1。

A4.

  1. 必要性:\(O\) 点与 \(P\) 点一定需要被照亮。
  2. 充分性:两点被同一灯照亮/两灯都有参与并且两灯有连接。
  3. 数学一下:两种情况两灯互换一下 四种结果取最小值。

------------------------代码分割线------------------------

A1.

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;map<int, int> cnt;for (int i = 1; i <= n; i++){int x;cin >> x;cnt[x]++;}int res = 0;auto cal = [](int n){return n * (n - 1) * (n - 2) / 6;};int has = 0;for (auto [x, k] : cnt){if (k >= 2)res += has * k * (k - 1) / 2;if (k >= 3)res += cal(k);has += k;}cout << res << endl;
}

A2.

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;int sum = 0;int odd = 0;for (int i = 0; i < n; i++){int x;cin >> x;sum += x;odd += x & 1 != 0;int k = 0;if (i){k = (odd + 2) / 3;if (odd % 3 == 2)k--;}cout << sum - k << ' ';}cout << endl;
}

A3.

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(6);int T = 1;cin >> T;while (T--)_();return 0;
}void _()
{int n;cin >> n;map<char, int> cnt;int max_cnt = 0;string s;cin >> s;for (auto v : s){cnt[v]++;max_cnt = max(max_cnt, cnt[v]);}int res = max(0ll, max_cnt - (n - max_cnt));if (n & 1)res = max(1ll, res);cout << res << endl;
}

A4.

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);cout << fixed << setprecision(10);int T = 1;cin >> T;while (T--)_();return 0;
}#define x first
#define y second
void _()
{pair<int, int> o, p, a, b;o.x = o.y = 0;cin >> p.x >> p.y >> a.x >> a.y >> b.x >> b.y;auto d = [](pair<int, int> a, pair<int, int> b){return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));};double res = min(max(d(a, o), d(a, p)), max(d(b, o), d(b, p)));res = min(res, max(d(a, b) / 2, min(max(d(a, o), d(b, p)), max(d(b, o), d(a, p)))));cout << res << endl;
}

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

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

相关文章

【前端】前端需要知道的缓存知识总结

引言📇 HTTP缓存是一种用于提高网站性能和减少带宽使用的技术。当用户访问一个网页时,浏览器会下载页面上的所有资源(如HTML、CSS、JavaScript等),这些资源会占用大量的带宽和时间。为了减少这些资源的加载时间,HTTP缓存机制被引入。 缓存分为强缓存和协商缓存两种,强缓…

[CF2057G] Secret Message 题解

神秘题目。 题目的条件十分神奇,\(|A| \le \frac{1}{5} (s+p)\),不知所云。 一开始尝试用皮克定理转化,但是 failed。 阅读理解之后发现有一个(很典)的套路,就是构造出五组方案,使得 \(\sum_{cyc} |A| = s+p\),这样就一定有一组方案,面积小于等于 $ \frac{1}{5} (s+p)…

装机重启后无法进入图形界面

装机重启后无法进入图形界面 A problem has occurred and the system cant recover. Please log out and try again. 主要原因可能是安装的软件包未更新,更新即可 (yum update) 报错截图首先进入命令行界面并登录root账户 Ctrl+Alt+F2联网 对于rocky系统,查看网络设备: nmcl…

【MATLAB】自学记录之基于某楼栋房价数据绘制三维网格图

1. 前言 基于某小区某一楼栋各个户型及楼层之间对应的出售价格表,通过MATLAB脚本进行读取解析,并绘制成三维网格图,从而能够直观地以可视化的角度观察户型位置(东边户、西边户、中间连廊户)、楼层位置(高中低楼层)等因素是否与出售价格存在一定的影响关系。2. 预置条件序…

【前端】谈谈水印实现的几种方式

遇到问题 日常工作中,经常会遇到很多敏感的数据,为防止数据的泄露,我们要在数据上做一些”包装“。目的就是让那些有心泄露数据的”不法分子“迫于严重的”舆论压力“而放弃不法行为,使之”犯罪未遂“,达到不战而屈人之兵的效果。而在安全部门工作的我们,数据安全的观念早…

插头DP记录

关于插头dp。AAA黑题批发。 这个东西好像设问还挺广泛的,做到哪写到哪吧。 得先了解一下轮廓线dp定义。 概念 设问广泛但是总体来说是连通性相关状压dp的一类设计方法。 骨牌覆盖问题 比如说,最简单的,问你 \(n*m\) 的棋盘格里能放多少 \(1*2\) 的骨牌。 考虑把一个节点分为…

03_LaTeX之文档元素

在知道了如何输入文字后,在本章了解一个结构化的文档所依赖的各种元素——章节、目录、列表、图表、交叉引用、脚注等等。目录03_\(\LaTeX{}\) 之文档元素章节和目录章节标题目录文档结构的划分标题页交叉引用脚注和边注特殊环境列表对齐环境引用环境摘要环境代码环境表格列格…

THREE.js学习笔记6——Geometries

这一小节学习THREE.js中的物理模型。 什么是geometry?(英文解释,翻译为中文就看不懂了,直接看英语吧)Composed of vertices (point coordinates in 3D spaces)and faces (triangles that join those vertices to create a surface) Can be used for meshes but also for par…

第三节 回归实战

数据处理超参:人为指定不能改变测试数据只有x没有标签y 训练数据拆分,82开,作训练集和验证集(验证模型好坏),模型训练不是一路上升的过程,训练几次验证一次,最好的模型save下来 one-hot独热编码 猪(1 0 0) 狗(0 1 0) 猫(0 0 1) def get_feature_importance(feature_data, label…

Windows git bash 文字显示/斜杠开头数字

前言全局说明Windows git bash 文字显示/斜杠开头数字一、说明 详细介绍:https://zhuanlan.zhihu.com/p/133706032二、问题三、解决方法 git config --global core.quotepath false免责声明:本号所涉及内容仅供安全研究与教学使用,如出现其他风险,后果自负。参考、来源: h…

DDR 带宽的计算与监控

DDR 带宽(Double Data Rate Bandwidth)是指 DDR 内存在一秒内可以传输的数据量,通常以 GB/s(Gigabytes per second) 为单位。它是衡量内存系统性能的重要指标,直接影响系统的数据吞吐能力。 1.如何计算 DDR 带宽 计算 DDR 理论带宽的公式为: DDR主频 * 位宽 = 理论带宽其…

1.15

尽力了,之前的粗心导致现在要改很多以前的坑,明天再继续