随笔分类 -  数据结构

摘要:DescriptionN(3 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long LL; 7 8 const int MAXN = 20010; 9 10 struct Node {11 int val, id;12 bool operator 0) {29 ret += tree[k];30 k -= lowbit(k);31 }32 return ret;33 }34 35 inline void modify(int... 阅读全文
posted @ 2013-08-14 23:22 Oyking 阅读(325) 评论(0) 推荐(0)
摘要:Yaroslav has an arrayp = p1, p2, ..., pn(1 ≤ pi ≤ n), consisting ofndistinct integers. Also, he hasmqueries:Query numberiis represented as a pair of integersli,ri(1 ≤ li ≤ ri ≤ n).The answer to the queryli, riis the number of pairs of integersq,w(li ≤ q, w ≤ ri)such thatpqis the divisor ofpw.Help Ya 阅读全文
posted @ 2013-08-14 12:26 Oyking 阅读(927) 评论(0) 推荐(1)
摘要:DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to... 阅读全文
posted @ 2013-08-01 16:12 Oyking 阅读(9756) 评论(0) 推荐(4)
摘要:DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickly k-th order statistics in the array segment.That is, given an array a[1...n] of differ 阅读全文
posted @ 2013-07-31 17:45 Oyking 阅读(366) 评论(0) 推荐(0)
摘要:DescriptionOnce in a forest, there lived N aggressive monkeys. At the beginning, they each does things in its own way and none of them knows each othe... 阅读全文
posted @ 2013-07-30 16:06 Oyking 阅读(287) 评论(0) 推荐(0)
摘要:DescriptionGiven a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0.We define this kind of operation: given a subtree, negate all its labels.And we want to query the numbers of 1's of a subtree.InputMultiple test cases.First line, two integerNandM, den 阅读全文
posted @ 2013-07-29 22:39 Oyking 阅读(292) 评论(0) 推荐(0)
摘要:DescriptionBob has traveled to byteland, he find the N cities in byteland formed a tree structure, a tree structure is very special structure, there is exactly one path connecting each pair of nodes, and a tree with N nodes has N - 1 edges.As a traveler, Bob wants to journey between those N cities, 阅读全文
posted @ 2013-07-28 00:02 Oyking 阅读(534) 评论(0) 推荐(0)
摘要:DescriptionWrite a program to transform the permutation1, 2, 3,...,naccording tominstructions. Each instruction(a,b)means to take out the subsequence from thea-th to theb-th element, reverse it, then append it to the end.InputThere is only one case for this problem. The first line contains two integ 阅读全文
posted @ 2013-07-27 18:27 Oyking 阅读(432) 评论(0) 推荐(0)
摘要:DescriptionYou are given an undirected graph with N vertexes and M edges. Every vertex in this graph has an integer value assigned to it at the beginning. You're also given a sequence of operations and you need to process them as requested. Here's a list of the possible operations that you m 阅读全文
posted @ 2013-07-26 23:14 Oyking 阅读(405) 评论(0) 推荐(0)
摘要:————————————————————————这些是转的,出处不明———————————————————————————————树状数组比较适合单个元素改变,反复求部分和,或者区间更新,单点求值。 先看的是一维的树状数组。 树状数组是一个很天才的想法,考虑这样的一种情景,对于一组数据,你经常要求他... 阅读全文
posted @ 2013-06-20 20:50 Oyking 阅读(1383) 评论(1) 推荐(0)
摘要:Sereja has a sequence that consists ofnpositive integers,a1, a2, ..., an.First Sereja took a piece of squared paper and wrote alldistinctnon-empty non-decreasing subsequences of sequencea. Then for each sequence written on the squared paper, Sereja wrote on a piece of lines paper all sequences thatd 阅读全文
posted @ 2013-06-12 15:16 Oyking 阅读(569) 评论(0) 推荐(0)