- 博客(18)
- 问答 (1)
- 收藏
- 关注
原创 警醒zz的自己
P1462 通往奥格瑞玛的道路 二分 迪杰斯特拉 最短路 堆优化的时候扔进去{dis[e[i].v],e[i].v} #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int > pii; typedef double db; #define rep(i,s,t) for(int i=s;i<=t;i++) #define per(i,s,t) for(int
2021-03-03 21:20:25 163 1
原创 DP 2
单调区间 最大子序和 #include<algorithm> #include<climits> #include<deque> #include<iostream> using namespace std; const int N=3e5+10; typedef long long ll; int n,m; deque<int> q; ll s[N]; int main(){ cin>>n>>m;
2021-03-03 17:06:49 93
原创 2021-03-02
质数距离 #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const int N = 1000010; int primes[N], cnt; bool st[N]; void init(int n) { memset(st, 0, sizeof st); cnt = 0; for
2021-03-02 21:30:56 79
原创 计算几何 1
点和向量 const double eps = 1e-10; struct Point { double x,y; Point(){} Point(double _x,double _y):x(_x),y(_y){} }; typedef Point Vector; //直线 struct Line { Point s, e; Line() {} Line(Point a, Point b) {s = a, e = b;} }; Vector operator+(const Vect
2021-03-02 18:48:18 148
原创 DP 1
最长上升子序列 int mx = 1; // 找出所计算的f[i]之中的最大值,边算边找 for (int i = 0; i < n; i++) { f[i] = 1; // 设f[i]默认为1,找不到前面数字小于自己的时候就为1 for (int j = 0; j < i; j++) { if (w[i] > w[j]) f[i] = max(f[i], f[j] + 1); // 前一个小于自己的数结尾的
2021-03-02 17:28:17 98
原创 数据结构——图的灵界矩阵存储
#include <iostream> using namespace std; const int DefaultVertices = 100; const int maxWeight = 1000; template<class T,class E> class Graphmtx { public: Graphmtx(int sz = DefaultVertices); ~Graphmtx() { delete[]VerticesList;
2021-02-14 11:13:35 168
原创 数据结构——二叉搜索树
不会写的,算导上有意外收获 #include<iostream> template <class E,class K> struct BSTNode { E data; BSTNode<E,K> *left,*right; BSTNode():left(NULL),right(NULL){} BSTNode(const E d,BSTNode<E,K> *L=NULL,BSTNode<E,K> *R=NULL):data(
2021-02-13 20:33:27 57
原创 数据结构——并查集
const int DefaultSize = 10; class UFSets { public: UFSets(int sz = DefaultSize); ~UFSets() { delete[] parent; } int Find(int x); void Union(int Root1, int Root2); private: int* parent; int Size; }; void UFSets::Union(int Root1, int
2021-02-13 17:38:23 84
原创 数据结构——最小堆
优先队列懒得打了 #include <iostream> //#include<priority_queue> using namespace std; const int DefaultSize=10; template<class T> class MinHeap { public: MinHeap(int sz = DefaultSize); //构造函数:建立空堆 MinHeap(T arr[], int n); //构造函数:通过一个数组创建堆 ~M
2021-02-13 17:23:31 163
原创 数据结构——二叉树
代码参考清华大学出版社的数据结构,吐了 #include <iostream> #include <cstdlib> #include <stack> #include <deque> using namespace std; template<class T> struct BinTreeNode { //广义表 T data; BinTreeNode<T>* leftChild, * rightChild;
2021-02-10 13:31:07 88
原创 数据结构——三元组实现稀松矩阵
#include <iostream> using namespace std; const int DefaultSize = 100; typedef int dt; struct Trituple {//三元组 int row, col; dt value; /*Trituple& operator=(Trituple& x) { row = x.row, col = x.col, value = x.value; }*/
2021-02-09 21:53:23 224
原创 数据结构——队列
循环队列 #include <iostream> #include <cassert> using namespace std; typedef int dt; const int maxSize = 50; class Queue { public: Queue(){} ~Queue(){} virtual void EnQueue(const dt& x) = 0; virtual bool DeQueue(dt& x) = 0;
2021-02-09 21:51:16 79
原创 数据结构——栈
顺序栈 #include <string> #include <iostream> #include <cstdio> using namespace std; typedef int DataType; class Node { public: DataType data; Node *next; }; class List { public: List(); ~List(); int Create(int size); int makeEmpty()
2021-02-09 21:49:35 108
原创 数据结构——链表
单链表 #include <iostream> using namespace std; typedef int dt; struct Node { Node* link; dt data; Node(Node* ptr = NULL) { link = ptr; } Node(const dt& item, Node* ptr = NULL) { data = item, link = ptr; } }; class List { public:
2021-02-09 21:47:31 141
原创 牛客2020跨年场
新年接着爬 A题最难了,抄个答案 D ABCD D A ABC C B C D D A C C D AD B 牛牛想起飞 int main(){ ios::sync_with_stdio(false); int n,y; cin>>n>>y; //y是取模数 for(int i=1;i<=n;++i) cin>>a[i]; for(int i=1;i<=n;++i) cin>>b[i];//a和b
2021-01-01 09:20:49 316
原创 线段树学习记录1
树 struct Node { int l,r; int data; }t[Max*4]; 因为左儿子和右儿子编号分别是父亲2和父亲2+1 所以要*4 建树 void build(int p,int l,int r){ t[p].l=l; t[p].r=r; if(l==r){ //具体操作 pushup return ; } int mid=(l+r)/2; build(p*2,l,mid); build(p*2+1,mid+1,r); //具体操
2020-12-27 15:03:19 113
原创 2020年浙大城市学院新生程序设计竞赛(同步赛)
这个比赛好芳香 啊啊啊啊 压力马斯达 2020年浙大城市学院新生程序设计竞赛同步赛 A 年轻人是不讲5的 众所周知,年轻人是不讲5的。作为年轻人,你应该继承这样的“优良传统”。 给定一个数串,输出时将其中的数字’5’替换成字符’*’。 签到题 string s; cin>>s; int l=s.size(); for(int i=0;i<l;i++){ if(s[i]=='5')s[i]='*'; } cout<<s<<endl; B 计算函数最大
2020-12-27 11:11:58 1881 1
原创 2020年广东工业大学第十届文远知行杯新生程序设计竞赛(同步赛)
第一次水题解,尽管还有三不会 链接 :https://ac.nowcoder.com/acm/contest/9692 A肥猪的钢琴床 做的时候没想到dp,直接模拟 转化后的字符串可化为 000111000三段,每一段的长度都可能为0 dp数组记录第i个处于第1/2/3段需要删除的最小字符(第个字符可能要被删除)正解是dp if(s[i]=='1') { dp[i][0]=dp[i-1][0]+1; dp[i][1]=min(dp[i-1][0],dp[i-1
2020-12-07 23:28:06 585
空空如也
关闭bios中的secure boot对系统有啥影响吗
2021-10-18
TA创建的收藏夹 TA关注的收藏夹
TA关注的人