随笔分类 - 数据结构
摘要:###True Liars ###题目描述: Peter有一个王国。在这个王国里,一共有2种人,即诚实人和撒谎人。诚实人永远说真话,撒谎人永远说假话。可惜的是,Peter只记得诚实人的数量和撒谎人的数量,但并不能确定每个人的身份。因此,他去民间收集了n组话语。每一组话语都是某人告诉Peter国王另一
阅读全文
摘要:树上启发式合并属于暴力的优化,复杂度O(nlogn) 主要解决的问题特点在于: 1.对于树上的某些信息进行查询 2.一般问题的解决不包含对树的修改,所有答案可以离线解决 算法思路:这类问题的特点在于父节点的信息是通过子节点更新而来 所以如果是暴力解决的话就是对每一个节点往下跑一次图,复杂度在O(n^
阅读全文
摘要:1 # include<iostream> 2 # include<cstring> 3 using namespace std; 4 const int N = 55; 5 int ne[N]; 6 7 char s[N],T[N]; 8 /*s为字串,T为主串*/ 9 int main(){ 1
阅读全文
摘要:1 # include<stdio.h> 2 # include<string.h> 3 # include<malloc.h> 4 # include<stdlib.h> 5 6 int peopleid = 20220200;/*最初的管理员编号*/ 7 int bookid = 0200200
阅读全文
摘要:1 # include<iostream> 2 # include<stdio.h> 3 # include<algorithm> 4 # include<string> 5 using namespace std; 6 /*建树的过程和二叉树大差不差*/ 7 const int N = 10001
阅读全文
摘要:# include<iostream># include<cstring># include<algorithm>using namespace std;const int N = 200010;typedef long long ll;/* 树状数组的主要目的是利用树形结构来优化前缀和 使得前缀和
阅读全文
摘要:1 # include<stdio.h> 2 # include<malloc.h> 3 typedef struct node { 4 int data;/*数据域*/ 5 struct node * next; /*指针域*/ 6 } node, *pnode; /*栈节点*/ 7 8 type
阅读全文
摘要:# include<stdio.h># include<malloc.h> typedef struct node{ int data; struct node *next;}node,*pnode;;int n;/*初始节点数目*/pnode creatlist();/*创建一个链表*/void
阅读全文
摘要:1 # include<iostream> 2 # include<cstring> 3 using namespace std; 4 const int N = 2e5 + 10; 5 6 struct node { 7 int l, r; 8 int v; 9 } tr[4 * N]; /*存树
阅读全文
摘要:# include<iostream># include<stdlib.h># include<queue># include<cstring>using namespace std;const int N = 10050;typedef struct Arcbox{ int tailvex,hea
阅读全文