自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 树链剖分

题目描述一棵树上有 nnn 个节点,编号分别为 111 到 nnn,每个节点都有一个权值 www。我们将以下面的形式来要求你对这棵树完成一些操作:I. CHANGE u t : 把结点 uuu 的权值改为 ttt。II. QMAX u v: 询问从点 uuu 到点 vvv 的路径上的节点的最大权值。III. QSUM u v: 询问从点 uuu 到点 vvv 的路径上的节点的权值和。注...

2020-03-12 12:58:00 132

原创 离散化+树状数组

题目描述Erwin最近对一种叫"thair"的东西巨感兴趣。。。在含有n个整数的序列a1,a2…an中,三个数被称作"thair"当且仅当i<j<k且ai<aj<ak求一个序列中"thair"的个数。输入格式开始一个正整数n,以后n个数a1~an。输出格式"thair"的个数思路:枚举中间的数字,求排在它前面,小于它的有几个。排在它后面,大于它的有几个...

2020-03-08 10:48:48 361

原创 线段树区间异或

题目描述AKN 觉得第一题太水了,不屑于写第一题,所以他又玩起了新的游戏。在游戏中,他发现,这个游戏的伤害计算有一个规律,规律如下拥有一个伤害串,是一个长度为 nnn 的只含字符 0 和字符 1 的字符串。规定这个字符串的首字符是第一个字符,即下标从 111 开始。给定一个范围 [l, r][l,~r][l, r],伤害为伤害串的这个范围内中字符 1 的个数会修改伤害串中的数值,修改的...

2020-03-08 02:30:06 1142

原创 P3121 [USACO15FEB]Censoring G

Farmer John 把杂志上所有的文章摘抄了下来并把它变成了一个长度不超过 10510^5105 的字符串 SSS。他有一个包含 nnn 个单词的列表,列表里的 nnn 个单词记为 t1⋯tnt_1 \cdots t_nt1​⋯tn​。他希望从 SSS 中删除这些单词。Farmer John 每次在 SSS 中找到最早出现的列表中的单词(最早出现指该单词的开始位置最小),然后从 SSS 中删...

2020-03-03 21:53:49 189

原创 poj 2688 Cleaning Robot (tsp问题)

DescriptionHere, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture.Consider the room floor paved with square tiles whose size fits the cleaning robot...

2020-02-17 19:32:18 254

原创 HDU 2222 Keywords Search

In the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description, w...

2020-02-12 13:53:25 88

原创 E - DNA Sequence POJ - 2778

It’s well known that DNA Sequence is a sequence only contains A, C, T and G, and it’s very useful to analyze a segment of DNA Sequence,For example, if a animal’s DNA sequence contains segment ATC then...

2020-02-12 02:15:59 161

原创 1123 Is It a Complete AVL Tree (30 分)

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...

2019-11-27 16:40:05 159

原创 1119 Pre- and Post-order Traversals (30 分)

Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder ...

2019-11-27 15:23:22 192

原创 1032 Sharing (25 分)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...

2019-11-22 21:27:39 234

原创 1028 List Sorting (25 分)

Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two i...

2019-11-22 20:50:29 95

原创 1086 Tree Traversals Again (25 分)

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac...

2019-11-22 20:20:11 113

原创 1097 Deduplication on a Linked List (25 分)

Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...

2019-11-22 19:40:11 114

原创 1133 Splitting A Linked List (25 分)

Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...

2019-11-22 17:52:55 138

原创 1131 Subway Map (30 分)

In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with you...

2019-11-22 16:54:05 231

原创 PAT甲级1155 Heap Paths (30 分)

In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...

2019-11-19 19:23:49 164

原创 PAT甲级1130

Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains...

2019-11-19 19:06:37 89

原创 PAT甲级1138 Postorder Traversal (25 分)

Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...

2019-11-18 21:23:11 178

原创 PAT甲级1020 Tree Traversals (25 分)

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...

2019-11-18 17:29:29 164

原创 1143 Lowest Common Ancestor (30 分)

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has t...

2019-11-17 13:49:51 320

原创 PAT甲级1088 Rational Arithmetic (20 分)

For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input file contains one test cas...

2019-11-15 16:10:31 152

原创 甲级1106 Lowest Price in Supply Chain (25 分)

1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Startin...

2019-11-13 23:18:28 125

原创 甲级1105 Spiral Matrix (25 分)

1105 Spiral Matrix (25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper...

2019-11-13 20:40:48 274

原创 1102 Invert a Binary Tree (25 分)

题意:给你一棵树,让你bfs一遍,然后中序遍历一遍。坑点:Invert这个单词的含义是反转的意思,也就是左右子树要互换。建树完了,跑一边遍历序列就好了。#include<bits/stdc++.h>#pragma GCC optimize(2)#define MAXN 15#define maxnode 1000005#define sigma_size 26#defin...

2019-11-13 17:27:54 110

原创 1053 Path of Equal Weight (30 分)

题意:给定一棵树,要求你遍历,输出路径和为要求值得路径。看大家写的那么 累,我来写一篇。思路:难点就是遍历,输出顺序要求是非降序,所以我们在建图的时候需要预处理,怎么办呢?将价值大的排在前面,所以我们直接建完图之后排序一遍就好了。具体看代码;#include<bits/stdc++.h>#pragma GCC optimize(2)#define MAXN 1...

2019-11-12 20:55:32 75

原创 PAT甲级--1144 The Missing Number (20 分)

Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives...

2019-08-14 12:57:52 94

原创 PAT--甲级 1101 Quick Sort (25 分)

There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le...

2019-08-14 10:20:03 86

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除