随笔分类 -  数据结构

摘要:题意:问你有n个长度总和为n的数组 你可以移动数组 但不能移出长度为w的矩形框 问你每一列的最大值是多少? 思路:只有一次询问 我们可以考虑差分来解决 然后对于每一行数组 我们可以用数据结构维护一下区间最大值 #include <bits/stdc++.h> using namespace std; 阅读全文
posted @ 2019-09-23 21:07 WAKBGAN 阅读(240) 评论(0) 推荐(0)
摘要:Problem Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let 阅读全文
posted @ 2019-09-06 18:26 WAKBGAN 阅读(169) 评论(0) 推荐(0)
摘要:Here is a square matrix of n * nn∗n, each lattice has its value (nn must be odd), and the center value is n * nn∗n. Its spiral decline along the cente 阅读全文
posted @ 2019-09-05 18:20 WAKBGAN 阅读(194) 评论(0) 推荐(0)
摘要:Problem Description Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flow 阅读全文
posted @ 2019-08-31 17:34 WAKBGAN 阅读(151) 评论(0) 推荐(0)
摘要:Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2, …, an. The initial values of them are 0. There are four 阅读全文
posted @ 2019-08-30 17:31 WAKBGAN 阅读(138) 评论(0) 推荐(0)
摘要:Problem Description There is a company that has N employees(numbered from 1 to N),every employee in the company has a immediate boss (except for the l 阅读全文
posted @ 2019-08-29 20:45 WAKBGAN 阅读(182) 评论(0) 推荐(0)
摘要:后缀数组(倍增): struct S_array{ int s[N],sa[N],t[N],t2[N],c[N],n; int f[N][20]; void build_sa(int m){ //字符个数 int i,*x=t,*y=t2; for(i=0;i<m;i++)c[i]=0; for(i 阅读全文
posted @ 2019-08-28 16:46 WAKBGAN 阅读(263) 评论(0) 推荐(0)
摘要:Problem Description You are given a string S consisting of only lowercase english letters and some queries.For each query (l,r,k), please output the s 阅读全文
posted @ 2019-08-28 16:43 WAKBGAN 阅读(163) 评论(0) 推荐(0)
摘要:Problem Description You are given an array a1,a2,...,an(∀i∈[1,n],1≤ai≤n). Initially, each element of the array is **unique**.Moreover, there are m ins 阅读全文
posted @ 2019-08-26 21:48 WAKBGAN 阅读(240) 评论(0) 推荐(0)
摘要:题意:给你一个n*m的的矩形框 现在又k条射线 问这个矩形框会被分为多少个区域 思路:之前的想法是枚举边界然后线段树扫一遍计算一下矩形个数 复杂度果断不行 后面发现其实答案就是交点数+1 然后就用线段树上下扫两边 阅读全文
posted @ 2019-08-20 19:43 WAKBGAN 阅读(199) 评论(0) 推荐(0)
摘要:题意:现在给你n个点 现在让你横着划三条线间距为r 然后竖着划三条线间距同样为r 现在让你求经过最多的点数 思路:我们首先建一棵关于y区间的线段树 然后枚举x轴 每次更新重叠的点 然后再更新回去 找一个最大值 阅读全文
posted @ 2019-08-18 13:13 WAKBGAN 阅读(309) 评论(0) 推荐(0)
摘要:题意:给你n个点 m条边的一张图 现在有q次操作 每次操作可以选择反转l~r的边号 也可以询问S(l)和S(r) 连接成的点集是否相同 思路:我们把m条边分块 用一个S数组维护每块对一个点的贡献 然后块间打标记 两端暴力 阅读全文
posted @ 2019-08-07 10:26 WAKBGAN 阅读(200) 评论(0) 推荐(0)
摘要:题意:给你一个n*m的矩阵 你只能向左向右相下走 有两种操作 q次询问 一种是把一个单位翻转(即可走变为不可走 不可走变为可走) 另一种是询问从(1,x) 走到 (n,y)有多少种方案 思路:题目n为1e5 而m只有10 我们可以考虑在线段树上维护一个m*m的矩阵 当模拟矩阵乘法的时候等效于计算方案 阅读全文
posted @ 2019-07-31 09:38 WAKBGAN 阅读(149) 评论(0) 推荐(0)
摘要:题目链接 题意:对于m次询问 求解以vi为根节点 深度为hi的的字母能不能组合成回文串。 思路:暴力dsu找一边 简直就是神技! 阅读全文
posted @ 2019-07-03 20:21 WAKBGAN 阅读(175) 评论(0) 推荐(0)
摘要:题目链接 题意:给你一棵以1为根n个点的树,问你以i为根的子树的众数和是多少 思路:dsu是一种优化暴力的手段 首先进行轻重链剖分 然后只记录重链的信息 轻链的信息就直接暴力查找 经过证明这样复杂度可以是nlogn。 阅读全文
posted @ 2019-07-03 16:32 WAKBGAN 阅读(210) 评论(1) 推荐(0)
摘要:You are given a tree with n nodes. The weight of the i-th node is wi. Given a positive integer m, now you need to judge that for every integer i in [1 阅读全文
posted @ 2019-05-03 17:37 WAKBGAN 阅读(199) 评论(0) 推荐(0)
摘要:Description Give a tree with n vertices,each edge has a length(positive integer less than 1001). Define dist(u,v)=The min distance between node u and 阅读全文
posted @ 2019-05-03 17:23 WAKBGAN 阅读(209) 评论(0) 推荐(0)
摘要:描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。 这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,都在这个词典里面找到以这个字符串开头的所有单词呢?” 身 阅读全文
posted @ 2019-03-03 18:51 WAKBGAN 阅读(182) 评论(0) 推荐(0)
摘要:Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. 阅读全文
posted @ 2019-03-03 18:14 WAKBGAN 阅读(300) 评论(0) 推荐(0)
摘要:Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, 阅读全文
posted @ 2019-03-03 17:28 WAKBGAN 阅读(148) 评论(0) 推荐(0)