随笔分类 - 数据结构
线性表(链表,栈,队列),二叉树,图。
摘要:https://www.luogu.com.cn/problem/P3368 题目大意: 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数加上x; 2.求出某一个数的值。 输入 #1复制 5 5 1 5 4 2 3 1 2 4 2 2 3 1 1 5 -1 1 3 5 7 2 4
阅读全文
摘要:https://www.luogu.com.cn/problem/P3374 题目大意: 有一个数组a,有两种操作: 一种是在x的位置上添加y; 一种是输出x到y位置上所有数字的和。 输入 #1 5 5 1 5 4 2 3 1 1 3 2 2 5 1 3 -1 1 4 2 2 1 4 输出 #1 1
阅读全文
摘要:https://www.acwing.com/problem/content/description/3558/ 输入样例: 1 8 4 2 3 4 5 6 -1 -1 -1 -1 7 -1 -1 8 -1 -1 -1 1 6 4 6 4 5 8 1 输出样例: 2 4 2 4 详解见代码内部 #i
阅读全文
摘要:https://www.acwing.com/problem/content/4881/ 输入样例1: 5 2 2 1 8 1 1 2 1 5 3 1 2 1 2 2 1 4 2 1 3 2 2 1 2 3 输出样例1: 3 6 4 输入样例2: 5 4 10 1 6 1 1 5 1 5 5 1 3
阅读全文
摘要:https://www.luogu.com.cn/problem/P1827 题目大意: 已知前序中序遍历 求后序遍历。 输入 #1 ABEDFCHG CBADEFGH 输出 #1 AEFDBHGC #include<bits/stdc++.h> using namespace std; typed
阅读全文
摘要:https://www.luogu.com.cn/problem/P1030 题目描述 给出一棵二叉树的中序与后序排列。求出它的先序排列。 输入格式 共两行,均为大写字母组成的字符串,表示一棵二叉树的中序与后序排列。 输出格式 共一行一个字符串,表示一棵二叉树的先序。 输入输出样例 输入 #1复制
阅读全文
摘要:https://www.luogu.com.cn/problem/P1160 //链表 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N=2002000,M=2002; const int I
阅读全文
摘要:https://atcoder.jp/contests/abc237/tasks/abc237_e 题目大意: 给定n个数字,m对边。 如果当前处于上坡状态,则两边的连接数值为:-2*(高的-矮的)【负权边】 如果当前属于下坡状态,则两边的连接数值为:高的-矮的 【正权边】 Sample Input
阅读全文
摘要:链接:https://ac.nowcoder.com/acm/contest/38457/B 他玩的游戏共有 n 个挑战房间,和 m 个 debuff。他非常强,只要不是带着所有的 debuff,他都能打过 boss 获得胜利。 进入第 i 个房间会使他带上编号在 [li,ri]上的所有 debuf
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/38718/B 题目描述 A城是一座繁忙又有活力的城市,随着城市的发展,原有的道路越发拥堵,所以政府决定对原有的道路交通系统进行改造。 A城目前的道路是这样的:城市中有n个交叉路口,部分交叉路口通过道路直接相连,任意两个交叉路口
阅读全文
摘要:https://codeforces.com/contest/1670/problem/C 这位佬写的挺不错的,强推 https://blog.csdn.net/qq_42883649/article/details/124644866?ops_request_misc=%257B%2522requ
阅读全文
摘要:https://codeforces.com/contest/1679/problem/C 您有一个大小为n×n的正方形棋盘。行从上到下编号为1到n,列从左到右编号为1到n。因此,每个单元格用一对整数(x,y) (1≤x,y≤n)表示,其中x是行号,y是列号。 您必须执行三种类型的q查询: 在单元格
阅读全文
摘要:https://www.acwing.com/problem/content/description/3543/ 输入一系列整数,利用所给数据建立一个二叉搜索树,并输出其前序、中序和后序遍历序列。 输入格式 第一行一个整数 n,表示输入整数数量。 第二行包含 n 个整数。 输出格式 共三行,第一行输
阅读全文
摘要:https://leetcode.cn/contest/weekly-contest-304/problems/longest-cycle-in-a-graph/ 给你一个 n 个节点的 有向图 ,节点编号为 0 到 n - 1 ,其中每个节点 至多 有一条出边。 图用一个大小为 n 下标从 0 开
阅读全文
摘要:PTA真的老喜欢出这种链表题欸 也好,涨知识了哦呦 e存储当前地址的值 ne存储当前节点地址的下一个地址 #include<bits/stdc++.h> using namespace std; const int N=200200; int e[N],ne[N]; int main() { cin
阅读全文