随笔分类 - 07.数据结构 - (03)线段树 & 树状数组
摘要:题目链接:https://codeforces.com/problemset/problem/567/D 题意: 在一个 1×n 的网格上,初始摆放着 k 只船,每只船的长度均为 a 个格子,已知所有船之间均不重叠、不触碰。 现在Bob每次询问Alice第 i 个格子上
阅读全文
摘要:题目链接:https://codeforces.com/gym/101908/problem/C 题意: 一块正方形披萨,有 H 刀是横切的,V 刀是竖切的,不存在大于等于三条直线交于一点。求最后切出多少片披萨。 题解: 横切和竖切分开考虑,如果横切的直线之间有 ans1 个交点,竖切
阅读全文
摘要:题目链接:https://codeforces.com/contest/1154/problem/E 题意: n 个人排成一排,第 i 个人的能力值为 a[i],a[1∼n] 是 1∼n 的某个排列。 第一个教练先来拉人,他会拉目前还在队伍中的 a[i]
阅读全文
摘要:题目链接:https://codeforces.com/problemset/problem/1136/E 题意: 给出一个 a[1∼n],以及一个 k[1∼(n−1)],初始保证所有的 1≤i≤n−1 都满足 $a[i]+k[i] \le a[i+1
阅读全文
摘要:题目链接:https://codeforces.com/contest/670/problem/E 题意: 给出一个已经匹配的括号串,给出起始的光标位置(光标总是指向某个括号)。 有如下操作: 1、往左移动一下光标; 2、往左移动一下光标; 3、删除当前光标指向的括号,以及和它匹配的那个括号,以及这
阅读全文
摘要:题目链接:https://zhixincode.com/contest/3/problem/J?problem_id=43 样例输入 1 4 1110 11 110 21 210 31 315 415 415 415 415 4 样例输出 1 28 题解: 首先是有个简单的想法,假设wls买完后,$
阅读全文
摘要:题目链接:https://zhixincode.com/contest/18/problem/C?problem_id=261 样例输入 1 4 21 23 4 样例输出 1 Yes 样例输入 2 4 31 22 33 4 样例输出 2 No 题解: 判断一个边集是否为最小边覆盖,用最笨的方法,暴力
阅读全文
摘要:题目链接:https://zhixincode.com/contest/22/problem/I?problem_id=314 样例输入 1 5 9 31 5 3 2 41 1 52 1 51 1 11 2 21 3 31 4 41 5 53 3 51 1 4 样例输出 1 151325413 题解
阅读全文
摘要:题目链接:https://codeforces.com/problemset/problem/1099/F Mitya and Vasya are playing an interesting game. They have a rooted tree with n vertices, and
阅读全文
摘要:题目链接:https://codeforces.com/contest/1089/problem/K time limit per test: 2 seconds memory limit per test: 512 megabytes King Kog got annoyed of the usu
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5542 Problem DescriptionCao Cao made up a big army and was going to invade the whole South China. Yu Zh
阅读全文
摘要:题目链接:https://www.nowcoder.com/acm/contest/211/E 题目描述 请实现一个数据结构支持以下操作:区间循环左右移,区间与,区间或,区间求和。 输入描述: 第一行n,q表示数列长度及操作次数。第二行n个数表示初始序列。接下来q行表示操作。 操作格式如下:一行表示
阅读全文
摘要:题目链接:https://nanti.jisuanke.com/t/31460 Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, each book ha
阅读全文
摘要:题目链接:https://nanti.jisuanke.com/t/31459 样例输入 3 1 4 4 1 3 3 样例输入 样例输出 10 样例输出 题意: 二维平面上给出 n 个点,每个点坐标 (x,y) 代表一个从原点到 $\left( {x,y} \r
阅读全文
摘要:题目链接:https://nanti.jisuanke.com/t/31451 Given a rooted tree ( the root is node 1 ) of N nodes. Initially, each node has zero point. Then, you need
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3642 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Descript
阅读全文
摘要:题目链接:https://nanti.jisuanke.com/t/30996 During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Dragon impriso
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6447 Problem DescriptionYJJ is a salesman who has traveled through western country. YJJ is always on jo
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1542 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descripti
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4578 Problem Description Yuanfang is puzzled with the question below: There are n integers, a1, a2, …,
阅读全文