03 2019 档案
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805047903240192 二叉搜索树或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值;若它的右子树不空,则右子树
阅读全文
摘要:#include using namespace std; const int maxn = 1e5 + 10; int N, root = 1; int vis[maxn], dep[maxn]; vector pre; vector lev[maxn]; int depth = -1; struct Node{ int val; int l; int r; }n...
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=2285 Problem Description 洪尼玛今天准备去寻宝,在一个n*n (n行, n列)的迷宫中,存在着一个入口、一些墙壁以及一个宝藏。由于迷宫是四连通的,即在迷宫中的一个位置,只能走到与它直接相邻的其他四个位
阅读全文
摘要:在老电影“007之生死关头”(Live and Let Die)中有一个情节,007被毒贩抓到一个鳄鱼池中心的小岛上,他用了一种极为大胆的方法逃脱 —— 直接踩着池子里一系列鳄鱼的大脑袋跳上岸去!(据说当年替身演员被最后一条鳄鱼咬住了脚,幸好穿的是特别加厚的靴子才逃过一劫。) 设鳄鱼池是长宽为100
阅读全文
摘要:https://pintia.cn/problem-sets/1111189748004499456/problems/1111189831248850957 现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。 输入格式: 输入数据
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805063166312448 火车站的列车调度铁轨的结构如下图所示。 两端分别是一条入口(Entrance)轨道和一条出口(Exit)轨道,它们之间有N条平行的轨道。每趟列车
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805066890854400 没有人没抢过红包吧…… 这里给出N个人之间互相发红包、抢红包的记录,请你统计一下他们抢红包的收获。 输入格式: 输入第一行给出一个正整数N(≤)
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805059118809088 一门武功能否传承久远并被发扬光大,是要看缘分的。一般来说,师傅传授给徒弟的武功总要打个折扣,于是越往后传,弟子们的功夫就越弱…… 直到某一支的某
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805068539215872 给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。 输入格式: 输入第一行给出一个正整数N(≤),随后
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805063963230208 战争中保持各个城市间的连通性非常重要。本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报。注意:若该
阅读全文
摘要:http://poj.org/problem?id=3461 Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He w
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1711 Problem Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ......
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805061769609216 呵呵。大家都知道五服以内不得通婚,即两个人最近的共同祖先如果在五代以内(即本人、父母、祖父母、曾祖父母、高祖父母)则不可通婚。本题就请你帮助一对
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805056736444416 在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805046946938880 给定一个全部由小写英文字母组成的字符串,允许你至多删掉其中 3 个字符,结果可能有多少种不同的字符串? 输入格式: 输入在一行中给出全部由小写英
阅读全文
摘要:A.Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair of different vertices, the weight of the edge between t
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805051153825792 本题要求你实现一个天梯赛专属在线地图,队员输入自己学校所在地和赛场地点后,该地图应该推荐两条路线:一条是最快到达路线;一条是最短距离的路线。题目
阅读全文
摘要:http://poj.org/problem?id=2234 Description Here is a simple game. In this game, there are several piles of matches and two players. The two player pla
阅读全文
摘要:http://codeforces.com/contest/1095 A. Repeating Cipher #include <bits/stdc++.h> using namespace std; int N; string s; string ans = ""; int main() { sc
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805057298481152 图着色问题是一个著名的NP完全问题。给定无向图G=(V,E),问可否用K种颜色为V中的每一个顶点分配一种颜色,使得不会有两个相邻顶点具有同一种颜
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/543#question A. 代码: #include <bits/stdc++.h> using namespace std; int N; vector<int> v; int main() { scanf("%d", &
阅读全文
摘要:https://vjudge.net/contest/289558#overview A - Frog Therearex frogs and y chicken in a garden. Kim found there are n heads and m legs in the garden. P
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805049870368768 将一系列给定数字顺序插入一个初始为空的二叉搜索树(定义为左子树键值大,右子树键值小),你需要判断最后的树是否一棵完全二叉树,并且给出其层序遍历的
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805055176163328 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,总评成绩必须达
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1848 Problem Description 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的:F(1)=1;F(2)=2;F(n)=F(n-1)+F(n-2)(n
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805053141925888 当你在社交网络平台注册时,一般总是被要求填写你的个人兴趣爱好,以便找到具有相同兴趣爱好的潜在的朋友。一个“社交集群”是指部分兴趣爱好相同的人的集
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805062432309248 学生互评作业的简单规则是这样定的:每个人的作业会被k个同学评审,得到k个成绩。系统需要去掉一个最高分和一个最低分,将剩下的分数取平均,就得到这个
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805064676261888 将一系列给定数字顺序插入一个初始为空的小顶堆H[]。随后判断一系列相关命题是否为真。命题分下列几种: x is the root:x是根结点;
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805069361299456 给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列。这里假设键值都是互不相等的正整数。 输入格式: 输入第一行给出一个正整数N(≤),
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805065406070784 给定一棵二叉树的中序遍历和前序遍历,请你先将树做个镜面反转,再输出反转后的层序遍历的序列。所谓镜面反转,是指将所有非叶结点的左右孩子对换。这里假
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805058485469184 微博上有个“点赞”功能,你可以为你喜欢的博文点个赞表示支持。每篇博文都有一些刻画其特性的标签,而你点赞的博文的类型,也间接刻画了你的特性。然而有
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805050709229568 喊山,是人双手围在嘴边成喇叭状,对着远方高山发出“喂—喂喂—喂喂喂……”的呼唤。呼唤声通过空气的传递,回荡于深谷之间,传送到人们耳中,发出约定俗
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805046577840128 在古老的迈瑞城,巍然屹立着 n 块神石。长老们商议,选取 3 块神石围成一个神坛。因为神坛的能量强度与它的面积成反比,因此神坛的面积越小越好。特
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805072641245184 给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805057860517888 给定一个单链表 L1→L2→⋯→Ln−1→Ln,请编写程序将链表重新排列为 Ln→L1→Ln−1→L
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805073643683840 作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图。在地图上显示有多个分散的城市和一些连接城市的快速道路。每个城市的救援队数量和每一条连
阅读全文
摘要:https://pintia.cn/problem-sets/994805046380707840/problems/994805107638517760 下面是新浪微博上曾经很火的一张图: 一时间网上一片求救声,急问这个怎么破。其实这段代码很简单,index数组就是arr数组的下标,index[0
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; #define LL long long const int mod = 1e9 + 7; const int maxn = 1e5 + 10; int N; int num[maxn]; LL dp[max
阅读全文
摘要:http://codeforces.com/contest/1118 A. Water Buying #include <bits/stdc++.h> using namespace std; int T; int main() { scanf("%d", &T); while(T --) { lo
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/371#question A.小睿睿的等式 #include <bits/stdc++.h> using namespace std; int N, K, M; int num[11] = {6, 2, 5, 5, 4, 5,
阅读全文
摘要:http://lx.lanqiao.cn/problem.page?gpid=T46 问题描述 153是一个非常特殊的数,它等于它的每位数字的立方和,即153=1*1*1+5*5*5+3*3*3。编程求所有满足这种条件的三位十进制数。 输出格式 按从小到大的顺序输出满足条件的三位十进制数,每个数占一
阅读全文
摘要:http://lx.lanqiao.cn/problem.page?gpid=T52 问题描述 给定一个长度为n的数列,将这个数列按从小到大的顺序排列。1<=n<=200 输入格式 第一行为一个整数n。 第二行包含n个整数,为待排序的数,每个整数的绝对值小于10000。 输出格式 输出一行,按从小到
阅读全文
摘要:http://lx.lanqiao.cn/problem.page?gpid=T47 问题描述 1221是一个非常特殊的数,它从左边读和从右边读是一样的,编程求所有这样的四位十进制数。 输出格式 按从小到大的顺序输出满足条件的四位十进制数。 代码:
阅读全文
摘要:http://lx.lanqiao.cn/problem.page?gpid=T7 问题描述 利用字母可以组成一些美丽的图形,下面给出了一个例子: ABCDEFG BABCDEF CBABCDE DCBABCD EDCBABC 这是一个5行7列的图形,请找出这个图形的规律,并输出一个n行m列的图形。
阅读全文
摘要:http://lx.lanqiao.cn/problem.page?gpid=T6 问题描述 对于长度为5位的一个01串,每一位都可能是0或1,一共有32种可能。它们的前几个是: 00000 00001 00010 00011 00100 请按从小到大的顺序输出这32种01串。 对于长度为5位的一个
阅读全文
摘要:https://vjudge.net/contest/285902#overview A.Marjar Cola #include <bits/stdc++.h> using namespace std; int T; int main() { scanf("%d", &T); while(T --
阅读全文