- 博客(13)
- 收藏
- 关注
原创 PAT A1126
题目链接注意点:1.注意判断的前提是连通图,忘记判断的话有20分。#include<cstdio>int G[510][510];int degree[510];bool vis[510];int n, v;int cnt = 0;void DFS(int a) { vis[a] = true; cnt++; for (int i = 1; i <= n; ...
2019-02-13 19:30:52
135
原创 PAT A1124
题目链接#include<cstdio>#include<string>#include<vector>#include<iostream>#include<map>using namespace std;vector<string> v;vector<string> ans;map<
2019-02-13 14:21:47
165
原创 PAT A1130
题目链接注意点:1.二叉树的静态写法,会涉及到根是谁的问题,可利用数组hashT记录有哪些节点是孩子2.添加左右括号可通过判断此节点是否有左右孩子节点,但要注意最外层的括号是没有的#include<cstdio>#include<string>#include<iostream>using namespace std;struct Node{ ...
2019-02-13 11:08:08
377
原创 PAT A1133
题目链接//重排静态链表的顺序, 根据题目要求遍历整个表,将符合条件的依次取出放入ans数组#include<cstdio>#include<vector> using namespace std;struct Node{ int id, data, next; int vis;};Node linklist[100010];int main() {...
2019-02-01 15:46:12
266
原创 PAT A1136
题目之前有3个测试点没过,是由于若输入的数本身就是回文数,直接输出即可。#include<cstdio>#include<string>#include<iostream>#include<algorithm>using namespace std;int main() { string a, ans; cin >> a...
2019-01-28 16:47:33
303
原创 PAT A1151 & A1143
A1151A1143这两题题型差不多,1143是二叉排序树,而1151是一般树。一般解法就是1.建树2.找出到节点的路径3.比较即可。但是1143这样做的话,会导致内存超限。A1151:#include&lt;cstdio&gt;#include&lt;vector&gt;#include&lt;cstring&gt;#include&lt;algorithm&g
2019-01-28 14:37:47
480
原创 PAT A1142
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 extende...
2019-01-25 21:44:35
320
原创 PAT A1140
1140 Look-and-say Sequence (20 分)Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, …where D is in [0, 9] except 1. The (n+1)st number is a kind...
2019-01-24 18:02:18
148
原创 PAT A1147
1147 Heaps (30 分)In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater t...
2019-01-24 15:49:39
188
原创 PAT A1148
1148 Werewolf - Simple Version (20 分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: “Playe...
2019-01-21 16:14:51
273
原创 PAT A1149
1149 Dangerous Goods Packaging (25 分)When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious troub...
2019-01-21 14:25:48
366
原创 PAT A1152
1152 Google Recruitment (20 分)In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL con...
2019-01-19 13:41:15
298
1
原创 PAT A1155
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Ma...
2019-01-19 13:11:12
417
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人