2025.2.15——1400

news/2025/2/15 21:38:53/文章来源:https://www.cnblogs.com/jkkk/p/18717435

2025.2.15——1400


A 1400

B 1400

C 1400

------------------------------------------------

  • 思维+位运算+思维/数学


A

  1. 单独对一个数进行分析什么情况下会有贡献。
  2. 在前面且所有比其小的数,都必须是最小前缀。
  3. 两个树状数组记录小的个数和最小前缀的个数。遍历维护信息可以做到不使用树状数组(思维点)。

B

  1. 模拟发现可以获得所有区间异或和。但没有证明只能获得所有区间异或和。猜一发。
  2. 数组元素种类最多只有256个,同类相消,前缀异或和最多也只有256种。

C

  1. 分类讨论+思维

------------------------代码------------------------

A

#include <bits/stdc++.h>
#define int long long //
#define endl '\n'     // attention: interactive/debug
#define el cout << endl
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
#define bugv(VEC)               \{                           \for (auto Vec : VEC)    \cout << Vec << ' '; \el;                     \}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;
}void _()
{int n;cin >> n;vector<int> a(n + 1);for (int i = 1; i <= n; i++)cin >> a[i];int res = 0;int lim = 1e12, mn = 1e12;for (int i = 1; i <= n; i++){res += mn < a[i] && a[i] < lim; // 有选择 并且 在合法区间mn = min(mn, a[i]);if (mn - a[i])lim = min(lim, a[i]);}cout << res << '\n';
}
// // 树状数组  快速求前缀和
// // 维护差分数组(区间加)  位置(统计个数) ...
// struct Tree
// {
//     int n;
//     vector<int> tr;
//     Tree(int n1)
//     {
//         n = n1 + 2;
//         tr.assign(n + 2, 0);
//     }
//     void add(int x, int c) // 加点
//     {
//         for (int i = x; i <= n; i += i & -i)
//             tr[i] += c;
//     }
//     int ask(int x) // 前缀查询
//     {
//         int res = 0;
//         for (int i = x; i; i -= i & -i)
//             res += tr[i];
//         return res;
//     }
//     int ask(int l, int r) // 区间查询
//     {
//         if (l > r)
//             return 0ll;
//         return ask(r) - ask(l - 1);
//     }
// }; //    Tree tr(n);  tr.add(x,c)// void _()
// {
//     int n;
//     cin >> n;
//     vector<int> a(n + 1);
//     for (int i = 1; i <= n; i++)
//         cin >> a[i];
//     Tree cnt(n), pre_cnt(n);//     int pre_mn = 1e12;
//     int res = 0;
//     for (int i = 1; i <= n; i++)
//     {
//         if (cnt.ask(1, a[i]) && cnt.ask(1, a[i]) == pre_cnt.ask(1, a[i]))
//             res++;
//         pre_mn = min(pre_mn, a[i]);
//         cnt.add(a[i], 1);
//         if (pre_mn == a[i])
//             pre_cnt.add(a[i], 1);
//     }
//     cout << res << '\n';
// }

B

#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC)               \{                           \for (auto Vec : VEC)    \cout << Vec << ' '; \cout << '\n';           \}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;
}void _()
{// srand(time(0));int n;cin >> n;vector<int> a(n + 1);for (int i = 1; i <= n; i++)// a[i] = rand() % 256;cin >> a[i];// bugv(a);set<int> s;s.insert(0);int pre = 0, res = 0;for (int i = 1; i <= n; i++){pre ^= a[i];for (auto x : s){res = max(res, pre ^ x);}s.insert(pre);}cout << res << '\n';
}

C

#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC)               \{                           \for (auto Vec : VEC)    \cout << Vec << ' '; \cout << '\n';           \}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;
}void _()
{int mx = -20;int n;cin >> n;vector<int> a(n + 1);for (int i = 1; i <= n; i++){cin >> a[i];mx = max(mx, a[i]);}vector<pair<int, int>> res;auto add = [&](int i, int j){a[i] += a[j];res.push_back({i, j});};if (mx < 1){for (int i = n - 1; i; i--){add(i, i + 1);}}else{int id = 1;for (int i = 1; i <= n; i++){if (a[i] == mx){id = i;break;}}int t = 10;while (t--){add(id, id);}add(1, id);for (int i = 2; i <= n; i++){add(i, i - 1);add(i, i - 1);}}// bool f = 1;// for (int i = 2; i <= n; i++)// {//     if (a[i] - a[i - 1] < 0)//     {//         f = 0;//     }// }// bug(f);cout << res.size() << '\n';for (auto [i, j] : res){cout << i << ' ' << j << '\n';}// bug(20ll << 44);// bugv(a);
}

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

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

相关文章

撑起计算机视觉半边天的ResNet【论文精读】

ResNet论文精读:深度残差学习如何重塑深度学习一、技术演进背景:深度网络的困境与突破 消失的梯度与退化问题 在ResNet提出之前,深度学习领域已通过VGGNet、GoogLeNet等模型验证了网络深度的重要性。然而,当网络深度超过20层时,研究者发现了一个反直觉现象:更深的网络反而…

2025多校冲刺省选模拟赛13

2025多校冲刺省选模拟赛13\(T1\) A. 逆序对 \(56pts\)原题: luogu P5972 [PA 2019] Desant部分分\(56pts\) :爆搜。点击查看代码 int a[50]; pair<int,ll>ans[50]; struct BIT {int c[50];int lowbit(int x){return x&(-x);}void add(int x,int val){for(int i=x;i…

使用 Git 命令和 Github 前须了解的知识

本文不包括 Git 命令的介绍与使用,只分享 Git 的关键概念与 Github 项目的基本工作流程。作者相信先了解它们对后续的学习和工作大有裨益。(如有错误和建议请大家评论告知)版本控制系统 VCS → Version Control System,版本控制系统 → 一个跟踪文件变化、记录修订情况、协…

leetcode hot 02

解题思路:找祖先从底向上递归后序遍历查找,遇到p,q或者空节点就直接返回对应值,当某个节点的左子树、右子树都返回了值,那么就说明该节点就是最近祖先节点,然后把该节点的值继续往上传,直到根节点返回结果。 /*** Definition for a binary tree node.* public class Tre…

Linux介绍及使用

一、linux介绍 1、Linux是一个免费、开源的操作系统,能多用户、多任务、支持多线程和多CPU的操作系统,相对windows更加稳定,在unix系统的基础上开发的系统; 注解:(1)免费:不要钱 (2)源代码公开 (3)多用户 :可以在不同用户操作 (4)多任务:同时执行多个任务 …

Maven 生命周期 Test 阶段遇到的一些问题

Q:无法使用@Test注解,报错 A:最初pom.xml中使用的Junit版本为3,Java 5于 2004 年发布,引入了注解作为语言的一部分。而Junit 3 是在这之前发布的,因此它无法使用注解,将pom.xml中的版本号改为<version>4.13.2</version>后问题解决,可使用@TestQ:在Maven启…

18. 信号

一、什么是信号在 Linux 中,信号是一种用于通知进程发生了某种事件的机制。信号可以由内核、其它进程或者命令行工具发送给目标进程。Linux 系统中由多种信号,每种信号都用一个唯一的数值表示。例如,常见的信号如下:SIGINT (2):这是当用户在终端按下 Ctrl+C 时发送给前台进…

【专题】DeepSeek技术颠覆or创新共赢,开启Al算法变革元年报告汇总PDF洞察(附原数据表)

原文链接: https://tecdat.cn/?p=39544 在科技飞速迭代的当下,人工智能领域正经历着深刻变革,AI Agent 的发展尤为引人瞩目。 随着数字化进程的加速,全球数据量呈指数级增长,如同为 AI Agent 的发展提供了丰沃土壤。海量数据不仅为模型训练提供了坚实基础,更驱动着 AI A…

Python梯度提升模型GBM生态学研究:SFS、RandomizedSearchCV预测黑腿蜱种群分布丰度可视化-

全文链接:https://tecdat.cn/?p=39232 原文出处:拓端数据部落公众号 广义线性模型一直是揭示自然种群分布和丰度背后生态过程的基础统计框架。然而,随着环境和生态数据的快速增长,分析这些大规模数据集需要更先进的统计方法。梯度提升树等现代机器学习框架,能有效识别复杂…

9.7.5 预测

这里的预测过程不是图\(9\)-$14,应该是下面这幅图,这里有误