04-树5. File Transfer (25) 时间限制 150 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it…
题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/670 5-8 File Transfer   (25分) We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possibl…
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any other? Input Specification:…
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any other? Input Specification:…
1013 Battle 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/toward that city are closed. We must know immediately if we need to repair any ot…
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maximum number of trees in the forest, and for any pai…
Description 神犇有一个n个节点的图.因为神犇是神犇,所以在T时间内一些边会出现后消失.神犇要求出每一时间段内这个图是否是二分图.这么简单的问题神犇当然会做了,于是他想考考你. Input 输入数据的第一行是三个整数n,m,T. 第2行到第m+1行,每行4个整数u,v,start,end.第i+1行的四个整数表示第i条边连接u,v两个点,这条边在start时刻出现,在第end时刻消失. Output 输出包含T行.在第i行中,如果第i时间段内这个图是二分图,那么输出"Yes"…
模板题..去网上学了可撤销的并查集.. /* 给定一个无向图,边的属性为(u,v,l,r),表示<u,v>可以通过的size为[l,r] 求出有多少不同的size可以从1->n 把每条边的范围[l,r]进行区间离散化然后 建立线段树,然后把每条边按范围更新进线段树里 对线段树进行dfs,同时维护一个可撤销的并查集,经过每个线段树结点都用结点里存的边去更新并查集 到了叶子结点,如果发现[1,n]在同一个集合里,说明联通,那么把这个区间的贡献算上 回溯时要对并查集进行撤销 */ #inclu…
1013 Battle 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/toward that city are closed. We must know immediately if we need to repair any othe…
题意: 输入一个正整数N(<=10000),接着输入N行数字每行包括一个正整数K和K个正整数,表示这K只鸟是同一棵树上的.输出最多可能有几棵树以及一共有多少只鸟.接着输入一个正整数Q,接着输入Q行每行包括两个正整数,输出它们是否在同一棵树上. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ]; int find_(int x){ if(x==f…
链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805063963230208 题目: 战争中保持各个城市间的连通性非常重要.本题要求你编写一个报警程序,当失去一个城市导致国家被分裂为多个无法连通的区域时,就发出红色警报.注意:若该国本来就不完全连通,是分裂的k个区域,而失去一个城市并不改变其他城市之间的连通性,则不要发出警报. 输入格式: 输入在第一行给出两个整数N(0 < N ≤ 500)和M(≤ 5000),…
链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805068539215872 题目: 给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数.人均房产面积及房产套数. 输入格式: 输入第一行给出一个正整数N(≤),随后N行,每行按下列格式给出一个人的房产: 编号 父 母 k 孩子1 ... 孩子k 房产套数 总面积 其中编号是每个人独有的一个4位数的编号:父和母分别是该编号对应的这个人的父母的编号(如…
在一个社区里,每个人都有自己的小圈子,还可能同时属于很多不同的朋友圈.我们认为朋友的朋友都算在一个部落里,于是要请你统计一下,在一个给定社区中,到底有多少个互不相交的部落?并且检查任意两个人是否属于同一个部落. 输入格式: 输入在第一行给出一个正整数N(≤),是已知小圈子的个数.随后N行,每行按下列格式给出一个小圈子里的人: K [ [ ⋯ [ 其中K是小圈子里的人数,[(,)是小圈子里每个人的编号.这里所有人的编号从1开始连续编号,最大编号不会超过1. 之后一行给出一个非负整数Q(≤),是查询…
题意: 输入一个正整数N(<=10000),接着输入N行每行包括一个人的ID和他双亲的ID以及他的孩子数量和孩子们的ID(四位整数包含前导零),还有他所拥有的房产数量和房产面积.输出一共有多少个块(所有有父子关系的点都视为处于同一块),以及每块的元素个数以及平均每人分得的房产数量和房产面积(保留三位小数),输出顺序按照房产面积降序,第二优先以ID升序. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&…
题意: 输入三个整数N,M,K(N<=1000,第四个数据1e5<=M<=1e6).有1~N个城市,M条高速公路,K次询问,每次询问输入一个被敌军占领的城市,所有和该城市相连的高速公路全部不能使用,求增加多少条高速公路可以使剩下N-1个城市联通.(原本城市之间可能不联通,假设原本联通只能通过第0,4个数据). trick: 同一份代码交很多次,有几次会第4个点超时.(存疑)建议采用g++而不是clang++ AAAAAccepted code: #include<bits/stdc…
题目如下: 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 find the root that results in a highest tree. Such a root is called the deepest root. Input Specificat…
用线段树维护每一块左右两侧的并查集, 同色合并时若不连通则连通块数-1, 否则不变 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include <string.h&g…
题目 输入格式 输出格式 每次x=1时,每行一个整数,表示这次旅行的开心度 输入样例 4 1 100 5 5 5 1 1 2 2 1 2 1 1 2 2 2 3 1 1 4 输出样例 101 11 11 数据 对于100%的数据, n ≤ 100000,m≤200000 ,data[i]非负且小于10^9 题解 类似于重复开根以及取模之类的操作都有个共性,就是重复取的次数非常少 以本题开根为例,当取到一定次数时,就会变为1 我们用树状数组维护区间和 用并查集维护当前位置往下[包括当前位置],最近…
传送门 先膜一下大佬->这里 据说这题正解是LCT,然而感觉还是线段树套并查集的更容易理解 我们对于行与行之间用线段树维护,每一行内用并查集暴力枚举 每一行内用并查集暴力枚举连通块这个应该容易理解,就是如果是同一个同色连通块的就用并查集连起来.那么怎么处理行与行之间的连通块嘞? 因为几行连起来可以看做一块,那么我们用$[1,n]$维护最上面一行的连通性,用$[n+1,n*2]$维护最下面一行的连通性,然后用$[n*2+1,n*4]$作为辅助 这一部分的细节还是看代码好了,写在注解里了 //min…
湫湫系列故事——设计风景线 Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 3930    Accepted Submission(s): 700 Problem Description 随着杭州西湖的知名度的进一步提升,园林规划专家湫湫希望设计出一条新的经典观光线路,根据老板马小腾的指示,新的风景线最好能建成环形,如果没有条件建成环形,…
http://poj.org/problem?id=1308 Description A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties.There is exactl…
05-树8 File Transfer(25 point(s)) We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to…
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any other? Input Specification:…
题目大意:将多个电脑通过网线连接起来,不断查询2台电脑之间是否连通. 问题来源:中国大学mooc 05-树8 File Transfer (25 分) We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send…
本博客的代码的思想和图片参考:好大学慕课浙江大学陈越老师.何钦铭老师的<数据结构> 代码的测试工具PTA File Transfer 1 Question 2 Explain First, we will put N elements in a array,the elements is from 1 to N.The element in the array stand for the number  of computer. C1 stand for a computer and C2 s…
最近研究.NET NATIVE,听说发布了第二个预览版,增加了X86支持,所以下,发现连接到的页面是:https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=53214一看就头疼,因为我就成功用FTM好用过.以前在XP和2003下还时常好用一下,自打换了WIN8就彻底歇菜了,研究为啥.. 先下载最新版本安装FTM,然后到安装目录,用带有管理员权限的CMD执行: regsvr32 gr…
这次的题让我对选择不同数据结构所产生的结果惊呆了,一开始用的是结构来存储集合,课件上有现成的,而且我也是实在不太会,150ms的时间限制过不去,不得已,看到这题刚好可以用数组,结果7ms最多,有意思!什么是时间复杂度,终于有了一次感性的认识.这题还有个check的要求,我用了一个链表来存储,感觉挺麻烦的,不知是否有更好的方法,题设要求及代码实现如下 /* Name: Copyright: Author: Date: 06/04/15 09:46 Description: We have a ne…
并查集 简单并查集:输入N,代表有编号为1.2.3……N电脑.下标从1开始.初始化为-1.合并后根为负数,负数代表根,其绝对值代表个数. We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file…
In this article, I am going to explain ,"How to Upload Images to the server using Cordova File Transfer Plugin and Asp.Net core Web API". Requirements Web API (you can use local IIS servers to host your API) Cordova Camera Plugin (cordova-plugin…
题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805069361299456 L2-006 树的遍历 (25 分)   给定一棵二叉树的后序遍历和中序遍历,请你输出其层序遍历的序列.这里假设键值都是互不相等的正整数. 输入格式: 输入第一行给出一个正整数N(≤30),是二叉树中结点的个数.第二行给出其后序遍历序列.第三行给出其中序遍历序列.数字间以空格分隔. 输出格式: 在一行中输出该树的层序遍历的序列.数字…