
图
文章平均质量分 83
感觉自己就是个bug
这个作者很懒,什么都没留下…
展开
-
PAT(甲级)2024夏季考试A-4
【代码】PAT(甲级)2024夏季考试A-4。原创 2024-06-21 19:04:23 · 219 阅读 · 0 评论 -
1018 Public Bike Management (30 分)
1018 Public Bike Management (30 分)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.The Public Bike原创 2021-03-12 10:47:37 · 115 阅读 · 0 评论 -
PAT(甲级)2019年秋季考试7-4 Dijkstra Sequence (30 分)
7-4 Dijkstra Sequence (30 分)Dijkstra’s algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from one particular source vertex to all the other vertices of the原创 2021-03-11 00:54:58 · 164 阅读 · 0 评论 -
PAT(甲级)2019年冬季考试7-3 Summit (25 分)
7-3 Summit (25 分)A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone.Now given原创 2021-03-11 00:55:29 · 118 阅读 · 0 评论 -
PAT(甲级)2020年冬季考试7-4 Chemical Equation (30分)
7-4Chemical Equation(30分)A chemical equation is the symbolic representation of a chemical reaction in the form of symbols and formulae, wherein the reactant entities are given on the left-hand side and the product entities on the right-hand side. For exam原创 2021-03-10 10:58:07 · 681 阅读 · 2 评论 -
PAT(甲级)2020年春季考试7-3 Safari Park (25 分)
7-3 Safari Park (25 分)A safari park(野生动物园)has K species of animals, and is divided into N regions. The managers hope to spread the animals to all the regions, but not the same animals in the two neighboring regions. Of course, they also realize that this原创 2021-03-10 11:00:25 · 165 阅读 · 0 评论 -
2020PAT甲级秋季7-4 Professional Ability Test (30分)
7-4Professional Ability Test(30分)Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is a prerequisite (前置要求) of Level B if one must pass Level A with a score no less than S in ord原创 2021-03-08 22:32:33 · 895 阅读 · 0 评论 -
1033 To Fill or Not to Fill (25 分)
1033 To Fill or Not to Fill (25 分)With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give di原创 2021-03-07 12:27:27 · 105 阅读 · 0 评论 -
1046 Shortest Distance (20 分)
1046 Shortest Distance (20 分)The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file contains one test case. For each原创 2021-03-06 11:47:39 · 71 阅读 · 0 评论 -
1048 Find Coins (25 分)
1048 Find Coins (25 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement原创 2021-03-06 11:44:47 · 84 阅读 · 0 评论 -
1072 Gas Station (30 分)
1072 Gas Station (30 分)A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.No原创 2021-03-03 15:00:29 · 80 阅读 · 1 评论 -
1076 Forwards on Weibo (30 分)
1076 Forwards on Weibo (30 分)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weibo原创 2021-03-03 10:22:45 · 70 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 分)
1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys prod原创 2021-03-03 09:54:12 · 66 阅读 · 0 评论 -
1087 All Roads Lead to Rome (30 分)
1087 All Roads Lead to Rome (30 分)Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each input file contains one原创 2021-03-02 15:14:09 · 151 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25 分)
1090 Highest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys pr原创 2021-03-01 15:11:08 · 63 阅读 · 0 评论 -
1106 Lowest Price in Supply Chain (25 分)
1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on the chain buys pro原创 2021-02-28 15:48:50 · 139 阅读 · 0 评论 -
1111 Online Map (30 分)
1111 Online Map (30 分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is guaranteed that a path exists for原创 2021-02-28 10:16:03 · 86 阅读 · 0 评论 -
1122 Hamiltonian Cycle (25 分)
1122 Hamiltonian Cycle (25 分)The “Hamilton cycle problem” is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a “Hamiltonian cycle”.In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle.Inp原创 2021-02-25 16:40:42 · 124 阅读 · 0 评论 -
1126 Eulerian Path (25 分)
1126 Eulerian Path (25 分)In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were first discussed by Leonhard Euler原创 2021-02-25 12:07:46 · 63 阅读 · 0 评论 -
1131 Subway Map (30 分)
1131 Subway Map (30 分)In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with your computer skills! Given the star原创 2021-02-24 23:16:11 · 99 阅读 · 0 评论 -
1134 Vertex Cover (25 分)
1134 Vertex Cover (25 分)A vertex cover of 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 are supposed to tell if each of them is a vertex cover o原创 2021-02-24 14:35:24 · 110 阅读 · 0 评论 -
1142 Maximal Clique (25 分)
1142 Maximal Clique (25 分)A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from ht原创 2021-02-23 13:24:26 · 116 阅读 · 0 评论 -
1150 Travelling Salesman Problem (25 分)
1150 Travelling Salesman Problem (25 分)The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origi原创 2021-02-22 16:47:01 · 93 阅读 · 0 评论 -
1030 Travel Plan (30分)
1030 Travel Plan (30分)A traveler’s map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path between his/her starting city and原创 2020-11-04 16:42:46 · 65 阅读 · 0 评论 -
1003 Emergency (25分)
1003 Emergency (25分)As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair原创 2020-11-04 16:02:42 · 87 阅读 · 1 评论 -
1034 Head of a Gang (30分)
1034 Head of a Gang (30分)One way that the police finds the head of a gang is to check people’s phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all th原创 2020-11-03 20:43:35 · 59 阅读 · 0 评论 -
PAT(甲级)2019年春季考试7-3 Telefraud Detection (25 分)
Telefraud Detection (25分)主要注重题目细节#include<bits/stdc++.h>using namespace std;int phone[1005][1005]={0},phone1[1005][1005]={0};vector<int>v[1005],w[1005];bool visit[1005][1005]={false},is[1005]={false},vs[1005]={false};void DFS(int root,in原创 2020-06-12 14:53:41 · 288 阅读 · 0 评论 -
1091 Acute Stroke (30分)-----BFS
https://pintia.cn/problem-sets/994805342720868352/problems/9948053754574110721091 Acute Stroke (30分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are原创 2020-06-07 14:58:25 · 119 阅读 · 0 评论 -
最小步数通过迷宫----BFS
最小步数通过迷宫----BFS问题描述:给定一个nm大小的迷宫,其中代表不可通过的墙壁,而"." 表示平地,S表示起点,T代表终点。移动过程中,如果当前位置是(x,y)(下标从0开始),且每次只能前往上下左右(x,y+1),(x,y-1),(x-1,y),(x+1,y)四个位置的平地,求从起点S到达终点T的最少步数#include<bits/stdc++.h>using namespace std;const int maxn=100;struct Node{ int x,y; /原创 2020-06-04 14:50:30 · 242 阅读 · 0 评论 -
矩阵中块的个数计算--BFS
矩阵中块的个数计算–BFS问题描述:给出一个m*n的矩阵,矩阵中的元素为0或1.称位置(x,y)与其上下左右四个位置(x,y+1),(x,y-1),(x+1,y),(x-1,y)是相邻的。如果矩阵中有若干个1是相邻的(不必两两相邻),那么称这些1构成了一个“块”。求给定矩阵中"块"的个数#include<bits/stdc++.h>using namespace std;const int maxn=100;struct Node{ int x,y; //位置(x,y); }n原创 2020-06-04 14:22:10 · 400 阅读 · 0 评论 -
1013 Battle Over Cities (25分)
https://pintia.cn/problem-sets/994805342720868352/problems/9948055004141158401013 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原创 2020-06-02 00:07:16 · 110 阅读 · 0 评论 -
1154 Vertex Coloring (25分)活用Set结构
1154 Vertex Coloring (25分)A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most k colors is called a (proper) k-coloring.Now you are suppos原创 2020-05-28 21:02:00 · 166 阅读 · 0 评论 -
图结构的邻接表表示及相关算法
图结构的邻接表表示#include<iostream>#include<queue>using namespace std;/*图的邻接表表示法*/#define MaxVertexNum 100 /*最大顶点数设为100*/typedef int Vertex; /*用顶点下标表示顶点,为整型*/typedef int WeightType; /*边的权值设为整型*/typedef char DataType;原创 2020-05-26 14:00:02 · 461 阅读 · 0 评论 -
08-图8 How Long Does It Take (25分)
08-图8 How Long Does It Take (25分).Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project.Input Specification:Each input file contains one test case. Each case starts with a line conta原创 2020-05-26 13:19:07 · 190 阅读 · 0 评论 -
08-图7 公路村村通 (30分)
08-图7 公路村村通 (30分)现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。输入格式:输入数据包括城镇数目正整数N(≤1000)和候选道路数目M(≤3N);随后的M行对应M条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路改建的预算成本。为简单起见,城镇从1到N编号。输出格式:输出村村通需要的最低成本。如果输入数据不足以保证畅通,则输出−1,表示需要建设更多公路。输入样例:6 151 2 5原创 2020-05-26 13:18:10 · 654 阅读 · 0 评论 -
07-图6 旅游规划 (25分)
07-图6 旅游规划 (25分)有了一张自驾旅游路线图,你会知道城市间的高速公路长度、以及该公路要收取的过路费。现在需要你写一个程序,帮助前来咨询的游客找一条出发地和目的地之间的最短路径。如果有若干条路径都是最短的,那么需要输出最便宜的一条路径。输入格式:输入说明:输入数据的第1行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的编号为0~(N−1);M是高速公路的条数;S是出发地的城市编号;D是目的地的城市编号。随后的M行中,每行给出一条高速公路的信息,分别是:城市1原创 2020-05-26 13:17:25 · 1502 阅读 · 0 评论 -
07-图5 Saving James Bond - Hard Version (30分)
07-图5 Saving James Bond - Hard Version (30分)This time let us consider the situation in the movie “Live and Let Die” in which James Bond, the world’s most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land at the cent原创 2020-05-26 13:16:40 · 476 阅读 · 0 评论 -
07-图4 哈利·波特的考试 (25分)
07-图4 哈利·波特的考试 (25分)哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠、老鼠变鱼的魔咒连起来念:hahahehe。现在哈利·波特的手里有一本教材,里面列出了所有的变形魔咒和能变的动物。老师允许他自己带一只动物去考场,要考察他把这只原创 2020-05-26 13:15:42 · 234 阅读 · 0 评论 -
06-图3 六度空间 (30分)
06-图3 六度空间 (30分)“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。“六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标。然而由于历史的原因,这样的研究具有太大的局限性和困难。随着当代人的联络主要依赖于电话、短信、微信以及因特网上即时原创 2020-05-26 13:14:57 · 179 阅读 · 1 评论 -
06-图2 Saving James Bond - Easy Version (25分)
06-图2 Saving James Bond - Easy Version (25分)This time let us consider the situation in the movie “Live and Let Die” in which James Bond, the world’s most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land at the cent原创 2020-05-26 13:13:39 · 154 阅读 · 0 评论