简单模拟
| 题目 | 摘要 |
|---|---|
| A1006 Sign In and Sign Out | |
| A1008 Elevator | |
| A1011 World Cup Betting | |
| A1036 Boys vs Girls | |
| A1042 Shuffling Machine | |
| A1046 Shortest Distance | |
| A1065 A+B and C (64bit) | |
| A1124 Raffle for Weibo Followers |
字符串处理
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1005 Spell It Right | ||
| A1035 Password | ||
| A1061 Dating | ||
| A1071 Speech Patterns | ||
| A1077 Kuchiguse | ||
| A1082 Read Number in Chinese | ||
| A1112 Stucked Keyboard | ||
| A1140 Look-and-say Sequence | github |
算法
排序
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1016 Phone Bills | 部分正确github | |
| A1025 PAT Ranking | github | |
| A1055 The World’s Richest | ||
| A1062 Talent and Virtue | github | |
| A1075 PAT Judge | TimeOut github | |
| A1080 Graduate Admission | 出现了一些典型错误 | github |
| A1083 List Grades | erase()函数返回值一定要赋给原来的迭代器 | github |
| A1089 Insert or Merge | 部分正确 | |
| A1098 Insertion or Heap Sort | ??和我理解的堆排序不一样 | |
| A1101 Quick Sort | 只通过了一个测试点,其他的都超时了。目前还优化不了。 | |
| A1113 Integer Set Partition | 没太读懂题目,莫名其妙地AC了。 | |
| A1117 Eddington Number | 又读不懂题了。 | |
| A1129 Recommendation System | 题意很简单,但是样例很奇怪,总结不出来推荐的规律。排序第一关键词是频率,但第二关键词很迷,不知道是替换算法的模式还是按出现的先后顺序。 | |
| A1141 PAT Ranking of Institutions | 两个样例超时,和IO方式无关,应该还是主体算法太低效。 | |
| A1153 Decode Registration Card of PAT | 两个样例超时 |
散列
| 题目 | 题解 |
|---|---|
| A1041 Be Unique | 第一次采用类存储每个数字及其出现次数,然后读取完成后删除重复元素。有两个样例超时,应该是读入数据很多。第二次改用维护两个向量,分别存储目前只出现一次的和已经重复出现的,成功AC,但是最后两个样例149ms,时间上很危险。 |
| A1050 String Subtraction | 时间换空间和对s2逐个遍历方法都不超时,但是样例3始终错误 |
| A1084 Broken Keyboard | 相对好解决 |
| A1092 To Buy or Not to Buy | 相对好解决 |
| A1120 Friend Numbers | 相对好解决 |
| A1121 Damn Single | 换了两种方法,第一种方法耗时,样例4未通过,第二种快,但是4和5都未通过 |
| A1144 The Missing Number | 元素去重存储,所以直接用set。要考虑缺失的数字可能在中间,可能在尾部。并且经过试错,测试样例的数字序列都是从1开始的。 |
| A1149 Dangerous Goods Packaging | 为了实现快速,用相对复杂的数据类型保存商品信息。主要错误出现在对商品列表重复商品的处理上,因为find函数是简单地比较元素相等,而实际上想实现的是只对商品名比较,所以当数据类型内其他信息不匹配时就会出现错误。要么对输入数据去重,要么自定义find函数,只比较商品名。第二种方法比较靠谱,因为准确地反映了目的,排除了各种样例情况可能带来的意外干扰。 |
| A1078 Hashing | 也许是理解题意的问题,有一个样例始终未通过。 |
| A1145 Hashing - Average Search Time | 理解题意有问题。 |
贪心
| 题目 | 题解 |
|---|---|
| A1033 To Fill or Not to Fill | 还没有好的解决思路 |
| A1037 Magic Coupon | AC |
| A1038 Recover the Smallest Number | 不会啊不会 |
| A1067 Sort with Swap(0, i) | 不会 |
| A1070 Mooncake | 部分正确,没找到错误 |
| A1125 Chain the Ropes | 读不懂题 -_- |
二分
| 题目 | 摘要 |
|---|---|
| A1085 Perfect Sequence | 题意没明白。要找出最多多少个数字可以组成完美序列,那样例的输出为什么不是10 |
| A1044 Shopping in Mars | 第一次暴力求解,直接按序遍历标价向量,挨个求完美序列,但是超时。改进遍历方法为保存好前次完美序列和其总价值,每次总价值减去完美序列第一个标价,也就是减去上一次遍历的起点标价,总价值等于应付结束,总价值小于应付则接着前次完美序列的最后一位继续往后加,总价值大于应付则从前次完美序列末尾开始减,直到总价大于等于应付。还有一个小问题就是,第二次改进的算法中在使用流式输入输出,第一次提交超时,但是第二次没有超时问题。 |
数学问题
| 题目 | 摘要 |
|---|---|
| A1001 A+B Format | PAT初体验 |
| A1002 A+B for Polynomials | |
| A1009 Product of Polynomials | |
| A1010 Radix | 把已知进制的数转换成十进制,然后从2进制开始尝试,找到能使两个数字相等的就输出。最后也找不到就输出Impossible。但是又未知的bug。对函数模块进行单独测试也没有发现问题。 |
| A1015 Reversible Primes | 开始没懂题意。逆置是指转换进制之后的序列进行逆置 |
| A1019 General Palindromic Number | 转换进制的问题 |
| A1023 Have Fun with Numbers | 容易解决,回文数字问题 |
| A1024 Palindromic Number | 回文数字问题 |
| A1027 Colors in Mars | 进制转换问题 |
| A1029 Median | 容易解决 |
| A1048 Find Coins | 始终有一个点超时 |
| A1058 A+B in Hogwarts | 特殊进位规则的加法 |
| A1059 Prime Factors | 涉及特殊算法,还不会 |
| A1060 Are They Equal | 转换为指定位数的科学计数法,测试没有发现问题,只有两个点通过 |
| A1069 The Black Hole of Numbers | |
| A1073 Scientific Notation | |
| A1081 Rational Sum | |
| A1088 Rational Arithmetic | |
| A1093 Count PAT’s | |
| A1096 Consecutive Factors | |
| A1104 Sum of Number Segments | |
| A1108 Finding Average | |
| A1116 Come on! Let’s C | |
| A1132 Cut Integer | |
| A1136 A Delayed Palindrome | |
| A1148 Werewolf - Simple Version | |
| A1152 Google Recruitment |
STL
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1022 Digital Library | ||
| 1023 Course List for Student | ||
| 1024 Student List for Course | ||
| 1025 The Dominnt Color | ||
| 1026 Set Similrity | ||
| 1027 Speech Ptterns | ||
| 1028 Mrs Numbers | ||
| 1039 | ||
| 1047 | ||
| 1054 | ||
| 1063 |
数据结构
链表
| 题目 | 摘要 |
|---|---|
| A1032 Sharing | |
| A1051 Pop Sequence | |
| A1052 Linked List Sorting | 采用了相当复杂的存储结构,利用map存储原始数据,然后重新生成链表,结点信息完备,又更新next信息,最后简单输出。但是超时而且有错。学习柳婼代码之后,改用大数组存储原始数据,链表只需要保存结点地址信息和数据即可,保存数据是为了给结点排序。然后直接输出,省去更新原表时间。 |
| A1056 Mice and Rice | |
| A1074 Reversing Linked List | 和1052开始的错误一样,修改后AC。重点就是链表要抓住结点地址。 |
| A1097 Deduplication on a Linked List | |
| A1133 Splitting A Linked List |
搜索
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1076 Forwards on Weibo | ||
| A1103 Integer Factorization | ||
| A1091 Acute Stroke | ||
| A1004 Counting Leaves | ||
| A1013 Battle Over Cities |
树
树的遍历
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1004 Counting Leves | ||
| 1005 Tree Trversls (25) | ||
| 1006 Pth of Equl Weight (30)(树的遍历) | ||
| 1007 Totl Sles of Supply Chin (25)(dfs,bfs,树的遍历) | ||
| 1008 Tree Trversls gin (25) | ||
| 1009 Highest Price in Supply Chin (25) | ||
| 1010 The Lrgest Genertion (25)(bfs,dfs,树的遍历) | ||
| 1011 Invert Binry Tree (25) | ||
| 1012 Lowest Price in Supply Chin (25)(dfs,bfs,树的遍历) | ||
| 1013 Counting Nodes in BST (30)(二叉树的遍历,dfs) | ||
| 1014 Pre nd Postorder Trversls (30)(前序后序转中序) | ||
| A1020 Tree Traversals | ||
| A1021 Deepest Root |
二叉搜索树
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1066 Root of AVL Tree | ||
| A1123 Is It a Complete AVL Tree |
平衡二叉树
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1066 Root of VL Tree (25) |
并查集
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1034 Head of a Gang | ||
| A1107 Social Clusters | ||
| A1114 Family Property | ||
| A1118 Birds in Forest |
堆
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1098 Insertion or Hep Sort | ||
| A1147 Heaps | ||
| A1155 Heap Paths |
树状数组
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1057 Stck (30)(树状数组) |
广义树
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1079 Total Sales of Supply Chain | ||
| A1090 Highest Price in Supply Chain | ||
| A1094 The Largest Generation | ||
| A1106 Lowest Price in Supply Chain | ||
| A1130 Infix Expression |
??
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1086 Tree Traversals Again | ||
| A1102 Invert a Binary Tree | ||
| A1053 Path of Equal Weight | ||
| A1064 Complete Binary Search Tree | ||
| A1043 Is It a Binary Search Tree | ||
| A1099 Build A Binary Search Tree | ||
| A1127 ZigZagging on a Tree | ||
| A1115 Counting Nodes in a BST | ||
| A1138 Postorder Traversal | ||
| A1110 Complete Binary Tree | ||
| A1143 Lowest Common Ancestor | ||
| A1151 LCA in a Binary Tree | ||
| A1135 Is It A Red-Black Tree |
图
图的遍历
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1013 Bttle Over Cities (25)(图的遍历,统计强连通分量的个数,dfs) | ||
| 1021 Deepest Root (25)(图的遍历,dfs,连通分量的个数) | ||
| 1034 Hed of Gng (30)(图的遍历dfs) | ||
| 1072 Gs Sttion (30)(Dijkstr) | ||
| 1076 Forwrds on Weibo (30)(图的遍历bfs) | ||
| A1134 Vertex Cover | ||
| A1122 Hamiltonian Cycle | ||
| A1126 Eulerian Path |
最短路径
| 题目 | 摘要 | 题解 |
|---|---|---|
| A1003 Emergency | ||
| A1018 Public Bike Management | ||
| A1030 Travel Plan | ||
| A1072 Gas Station | ||
| A1087 All Roads Lead to Rome | ||
| A1111 Online Map |
动态规划
| 题目 | 摘要 | 题解 |
|---|---|---|
| 1007 Mximum Subsequence Sum (25)(动态规划dp) | ||
| 1040 Longest Symmetric String (25)(动态规划) | ||
| 1045 Fvorite Color Stripe (30) | ||
| 1068 Find More Coins (30)(01背包) |
这篇博客深入探讨了算法在实际问题中的应用,包括排序算法的优化、图的遍历策略以及动态规划的解题思路。作者通过实例分析了快速排序、二分查找、最短路径计算,并展示了如何运用动态规划解决最长递增子序列和背包问题。同时,还讨论了图的深度优先搜索和广度优先搜索在社交网络分析中的应用。

910





