STL
文章平均质量分 59
Prime me
Nobody can defeat me unless I don't want to win.
展开
-
算法:线性时间选择(随机快排与STL)
算法:线性时间选择给定线性序集中n个元素和一个整数k,n<=2000000,1<=k<=n,要求找出这n个元素中第k小的数。做法 :每次对数组进行随机选择一个数(此处我的选择是数组中间点),将其作为节点对其左右两边的数组进行划分,使其左边的部分数组小于其右边的数组,然后返回该数现在的坐标,作为quicksort返回值,然后比较该返回值与题目要求的第k值,如果恰好为该点则返回主函数并输出,若是大于k就在左边数组进行下一次划分,反之则进入右边进行。#include <stdio原创 2021-12-08 20:39:39 · 722 阅读 · 0 评论 -
set基本介绍及使用方法
我对set的认识始于牛客竞赛A题。在使用数组去解决问题失败之后我果断放弃了这个题。晚上结束之后开始了我的set学习之路。set 暂时说一下我目前对他的认知吧。1: set自带查重功能,在重复输入两个相同的值之后,set只会存储一个值。2: set自带排序功能,在输入进去值之后,set从前begin到end的值的排序为从小到大排序。头文件:#include 。。#include 下面具体说明一下set的具体操作。1:begin() ,返回一个迭代器,返回的值为set容器的原创 2021-04-04 19:03:33 · 1773 阅读 · 2 评论 -
优先队列(priority_queue)详解版(C++)
头文件#include 他和queue不同的就在于我们可以自定义其中数据的优先级, 让优先级高的排在队列前面,优先队列和队列的特性有许多不同之处,包括数据结构底层实现和存储顺序,因为这基础上添加了内部的一个排序,它本质是一个堆实现的。常用的基本操作为:top 访问队头元素empty 队列是否为空size 返回队列内元素个数push 插入元素到队尾 (并排序)emplace 原地构造一个元素并插入队列pop 弹出队头元素priority_queue<Type, Container,原创 2021-11-22 20:35:42 · 994 阅读 · 0 评论 -
Monopoly(ccpc大学生程序竞赛补题)(前缀和加二分)
http://acm.hdu.edu.cn/showproblem.php?pid=7130第一步先求出前缀和和总和。判断sum值在不同情况下的处理情况。当sum==0,所有的数据只会在第一轮中出现一次。即若不在第一次中出现就不会出现。当sum<0时,将前缀和全部反转,并标记已翻转。将前缀和存入对应的取模后的map中进行存储,按照前缀和大小进行排序。然后二分查找若能找不到对应的取模值则输出-1,找到对应取模值后将前缀和值在数组中的位置取出。若取出值为最后,即为找不到对应值(只是对应的取模.原创 2021-11-08 19:03:37 · 257 阅读 · 0 评论 -
Shuffle Cards(伸展树STL)()
#include<bits/stdc++.h>#include<ext/rope>using namespace std;using namespace __gnu_cxx;rope<int>c,b;int num;signed main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { c.push_back(i);原创 2021-10-14 20:44:36 · 76 阅读 · 0 评论 -
K Segment Routing
Segment Routing over IPv6 is a next-generation IP bearer protocol.In traditional IP routing, an IP packet sent from a source host goes through multiple routers and then reaches the destination host. Each router checks the destination IP address inside th.原创 2021-09-23 22:02:03 · 133 阅读 · 0 评论 -
H Mesh Analysis
In computer graphics (CG), it is general to use a triangle mesh to represent the surface of an object.The 3-D points in a CG program form multiple connected line segments and triangles, which are in turn organized as a triangle mesh. You are asked to fin.原创 2021-09-23 20:36:53 · 149 阅读 · 0 评论 -
I Neiborhood(The 2021 ICPC Asia Regionals Online Contest (I))
We have a set S of one-dimensional points.Given a target point A, we would like to find the neighboring points of A in S. We consider two points are neighbors, if and only if they are within a distance of r.InputThe first line lists all the coordinates.原创 2021-09-20 12:34:08 · 146 阅读 · 0 评论 -
D. Jogging
Pheobe has heard that exercise has a tremendous affect on both physical and mental health. She never went jogging before, and she wants to try it out. However, she knows that she gets bored quickly and it is difficult for her to repeatedly do the same thi.原创 2021-08-24 08:43:48 · 283 阅读 · 0 评论 -
Gratitude
Ben heard about studies by Emmons and McCullough that suggest that intentionally practicing gratitude has a lasting effect on people’s happiness. Since he wants to be happy too, he decided that at the end of each day he will think back over the past day a.原创 2021-08-23 14:57:58 · 203 阅读 · 0 评论 -
STL使用说明
STL主要包含于以下十三个头文件中、、、、、、、、、、、,&&using namespace std#include<stdio.h>#include<stack>using namespace std;int main(){ char a,b,c; stack<char> s; //入栈 scanf("%c",&a);//输入字符a s.push(a);//将a存入栈内 b=s.t原创 2021-06-05 16:43:54 · 178 阅读 · 0 评论