自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 1107 Social Clusters

1107Social Clusters(30分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobb...

2019-11-26 22:01:47 101

原创 并查集【模板】

7-7并查集【模板】(30分)给出一个并查集,请完成合并和查询操作。输入格式:第一行包含两个整数N、M,表示共有N个元素和M个操作。接下来M行,每行包含三个整数Z​i​​、X​i​​、Y​i​​。当Z​i​​=1时,将X​i​​与Y​i​​所在的集合合并。当Z​i​​=2时,输出X​i​​与Y​i​​是否在同一...

2019-11-26 21:28:06 206

原创 参与者人数

7-6参与者人数(20分)临沂大学有很多社团,一个学生可能会加入多个社团。为了活跃大学生业余生活,增强体育运动积极性,临沂大学读书社团决定举行大学生跳绳比赛,要求该社团成员必须参加。为了扩大影响,要求只要其他社团有一个人参加,那么该社团中的每一个人都必须参加。求参加比赛至少多少人?输入格式:输入第一行包含...

2019-11-26 21:19:52 821

原创 文件传输

7-5文件传输(25分)当两台计算机双向连通的时候,文件是可以在两台机器间传输的。给定一套计算机网络,请你判断任意两台指定的计算机之间能否传输文件?输入格式:首先在第一行给出网络中计算机的总数N(2≤N≤10​4​​),于是我们假设这些计算机从 1 到N编号。随后每行输入按以下格式给出:I c...

2019-11-26 21:04:20 142

原创 部落

7-3部落(25分)在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈。我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同一个部落。输入格式:输入在第一行给出一个正整数N(≤10​4​​),是已知...

2019-11-26 20:51:16 195

原创 朋友圈

7-2朋友圈(25分)某学校有N个学生,形成M个俱乐部。每个俱乐部里的学生有着一定相似的兴趣爱好,形成一个朋友圈。一个学生可以同时属于若干个不同的俱乐部。根据“我的朋友的朋友也是我的朋友”这个推论可以得出,如果A和B是朋友,且B和C是朋友,则A和C也是朋友。请编写程序计算最大朋友圈中有多少人。输入格式:输...

2019-11-26 20:35:51 165 1

原创 1155 Heap Paths

1155Heap Paths(30分)In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key...

2019-11-24 21:41:21 56

原创 1147 Heaps

1147Heaps(30分)In computer science, aheapis a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the ke...

2019-11-24 21:25:44 76

原创 1123 Is It a Complete AVL Tree

1123Is 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 ...

2019-11-24 19:58:05 62

原创 1066 Root of AVL Tree

1066Root of AVL Tree(25分)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...

2019-11-24 19:46:25 62

原创 1154 Vertex Coloring

1154Vertex Coloring(25分)Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color...

2019-11-24 19:29:30 54

原创 1134 Vertex Cover

1134Vertex Cover(25分)Avertex coverof a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you...

2019-11-24 19:15:38 85

原创 1021 Deepest Root

1021Deepest Root(25分)A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to...

2019-11-24 19:04:03 89

原创 1013 Battle Over Cities

1013Battle Over Cities(25分)It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/to...

2019-11-24 18:46:41 80

原创 1099 Build A Binary Search Tree

1099Build A Binary Search Tree(30分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains...

2019-11-23 12:02:06 84

原创 1106 Lowest Price in Supply Chain

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

2019-11-22 16:51:49 85

原创 1094 The Largest Generation

1094The Largest Generation(25分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is t...

2019-11-22 16:39:29 77

原创 1090 Highest Price in Supply Chain

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

2019-11-22 16:29:38 60

原创 1079 Total Sales of Supply Chain

1079Total Sales of Supply Chain(25分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from sup...

2019-11-22 16:11:19 67

原创 1138 Postorder Traversal

1138Postorder Traversal(25分)Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are su...

2019-11-22 15:30:13 76

原创 1127 ZigZagging on a Tree

1127ZigZagging on a Tree(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 postorde...

2019-11-22 15:12:42 354

原创 1115 Counting Nodes in a BST

1115Counting Nodes in a BST(30分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contai...

2019-11-22 15:11:48 117

原创 1102 Invert a Binary Tree

1102Invert a Binary Tree(25分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a b...

2019-11-22 15:10:20 52

原创 1004 Counting Leaves

1004Counting Leaves(30分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specificati...

2019-11-22 15:08:44 44

原创 1053 Path of Equal Weight

1053Path of Equal Weight(30分)Given a non-empty tree with rootR, and with weightW​i​​assigned to each tree nodeT​i​​. Theweight of a path fromRtoLis defined to...

2019-11-22 15:06:00 70

转载 黄金矿工

你要开发一座金矿,地质勘测学家已经探明了这座金矿中的资源分布,并用大小为m * n 的网格 grid 进行了标注。每个单元格中的整数就表示这一单元格中的黄金数量;如果该单元格是空的,那么就是 0。为了使收益最大化,矿工需要按以下规则来开采黄金:每当矿工进入一个单元,就会收集该单元格中的所有黄金。矿工每次可以从当前位置向上下左右四个方向走。每个单元格只能被开采(进入)一次。不得开采(...

2019-11-02 21:48:36 517

原创 岛屿数量

给定一个由'1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。示例 1:输入:11110110101100000000输出:1示例2:输入:11000110000010000011输出: 3class Solution {publi...

2019-11-02 21:44:43 145

原创 浙大19年保研上机之 Index of Popularity

Index of PopularityTheindex of popularity(IP) of someone in his/her circle of friends is defined to be the number of friends he/she has in that cir...

2019-09-26 22:11:12 373 2

原创 浙大19年保研上机之 Is It An AVL Tree

Is It An AVL TreeIn computer science, an AVL tree (Georgy Adelson-Velsky and Evgenii Landis' tree, named after the inventors) is a self-balancing bina...

2019-09-26 22:08:54 391

原创 浙大19年保研上机之 pat-Zigzag Sequence

Zigzag SequenceThis time your job is to output a sequence ofNpositive integers in azigzag formatwith widthMin non-decreasing order. A zigzag ...

2019-09-26 22:06:24 505 1

原创 浙大19年保研上机之 pat-Happy Numbers

Happy NumbersAhappy numberis defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of ...

2019-09-26 22:03:39 191

原创 ccf csp 201604-4游戏

#include <iostream>#include<bits/stdc++.h>using namespace std;#define P pair<int,int>struct Node{ int st,end;//危险的开始时刻、结束时刻 Node(int s=0,int en=0) { st=s;...

2019-09-14 10:28:52 156

原创 pat1120 Friend Numbers

1120Friend Numbers(20分)Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 12...

2019-09-07 18:42:12 75

原创 pat1116 Come on! Let's C

1116Come on! Let's C(20分)"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. ...

2019-09-07 18:40:34 81

原创 pat1113 Integer Set Partition

1113Integer Set Partition(25分)Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA​1​​andA​2​​ofn​1​​an...

2019-09-07 18:39:10 70

原创 pat1108Finding Average

1108Finding Average(20分)The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that som...

2019-09-07 18:37:46 103

原创 Sunny Code1005还原二叉树

还原二叉树Problem Description给一棵二叉树的层序遍历序列和中序遍历序列,求这棵二叉树的先序遍历序列和后序遍历序列。Input每个输入文件中一组数据。第一行一个正整数N(1<=N<=30),代表二叉树的结点个数(结点编号为1~N)。接下来两行,每行N个正整数,分别代表二叉树的层序遍历序列和中序遍历序列。数据保证序列中1~N的每个数出现且只出现一次。...

2019-09-06 17:06:11 89

原创 Sunny Code1038古剑奇谭三:关键系统

古剑奇谭三:关键系统Problem Description现在我们定义,对两个系统,只要有其中一个系统的产物能用在另一个系统中,那么就称这两个系统“有关联”,且它们处于同一个“关联网”中;如果一个系统与一个关联网中的某个系统有关联,则称这个系统也在这个关联网中。在此基础上,在一个关联网中,如果让其中一个系统消失,...

2019-09-06 17:04:15 209

原创 Sunny Code1034极大独立集

极大独立集Problem Description对一个给定的无向图G(V,E),点集V'是V的子集。如果V'中的任意两个顶点之间都没有边,就称点集V'是图G的独立集(Independent Set)。在此基础上,如果往V'中添加任何一个在V中但不在V'中的顶点,都会使V'变成非独立集,那么就称V'是图...

2019-09-05 21:21:00 401

原创 Sunny Code 1043极大匹配

极大匹配Problem Description对给定的无向图G=(V,E),如果边集E'满足:(1)E'是E的子集;(2)E'中的任意两条边都没有公共顶点,那么称边集E'为图G的一个匹配(Matching)。而如果往E'中增加任意一条在E中但不在E'中的边,都会导致E'不再是图G的匹配,那么称E'为...

2019-09-05 20:20:45 404 1

空空如也

空空如也

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

TA关注的人

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