TaphoL4ACM
TaphoL4ACM
全部文章
分类
归档
标签
去牛客网
登录
/
注册
TaphoL4ACM的博客
全部文章
(共19篇)
题解 | 田忌赛马 | 贪心:总是将田忌较好与齐威王较差的两匹马进行对比
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ vector<int> nums1(3); for...
2026-05-09
1
4
题解 | 哈希冲突 | 性价比低的题目请直接放弃
//由于C++没有直接支持SHA256加密,我们贴心的花了将近100行代码帮你实现了这个功能。你需要补全的代码在第132行qwq #include <bits/stdc++.h> using namespace std; int enc_len; string enc_key; co...
2026-05-08
1
8
题解 | 生词篇章查询 | ump建立映射 ust去重
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespac...
2026-05-08
1
8
题解 | 两个数组的交集 | 双指针法代替unorder_map
#include <algorithm> #include <vector> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * ...
2026-05-08
1
9
题解 | 两端问优先队列 | multiset实现
#include <iostream> #include <set> using namespace std; void op1(multiset<int>& mst){ int x;cin>>x; mst.insert(x)...
2026-05-08
1
8
题解 | 宝石计数 | 多种哈希表的实现方式 | 这里是栈上数组法
1. 平衡二叉搜索树 — std::set / std::map底层数据结构红黑树(自平衡二叉搜索树),元素按键值有序存储。时间复杂度插入、删除、查找:O(log n) 平均 & 最坏遍历有序:O(n)前驱后继(lower_bound/upper_bound):O(log n)空间复杂度O(...
2026-05-07
1
10
题解 | 快乐数 | Floyd判圈法
slow 每次走一步,fast 每次走两步。如果存在循环,快慢指针必定相遇;循环结束条件:任一指针到达 1 或者两者相遇。最后只要任何一个为 1 就是快乐数。 class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法...
2026-05-07
1
6
题解 | 数对计数 | 哈希表(官方:集合方法)
#include <iostream> #include <unordered_map> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false);cin.tie...
2026-05-07
1
6
题解 | 参议院投票 | 贪心+队列模拟
使用两个队列分别存储 R 和 D 阵营参议员的原始位置(索引)。每一轮,从两个队列中各取一个队首元素(即当前轮次最先行动的两位参议员,因为队列按索引从小到大存储)。比较两个索引:如果 R 的索引 < D 的索引,说明 R 先行动,他可以禁止掉这名 D 参议员(并从 D 队列中移除该元素),然后...
2026-05-07
1
10
题解 | 队列消数 | 分类讨论一次遍历
对前面的人(包括自己):每人最多买 tickets[k] 张,贡献 min(tickets[i], tickets[k])张票对后面的人:在第 k 个人完成时,最多需要买 tickets[k]-1 张,贡献 min(tickets[i], tickets[k]-1张票 class Solution ...
2026-05-07
1
9
首页
上一页
1
2
下一页
末页