自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 1026 Table Tennis (30分)

据说是PAT最难的一道模拟题,情况很复杂,第二次做了,依旧是折磨人的小妖精(* ̄︶ ̄)。这次主要是栽在条件判断上了,一定要小心数组越界!而且这种错很难找(代码里※标注的地方,就是我找错找了好久的地方)#include <iostream>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <map>#incl

2020-07-24 16:20:18 202

原创 1127 ZigZagging on a Tree (30分)

根据两个遍历建树,把同一深度的节点从左到右存入一个vector,然后根据题意输出。#include<iostream>#include<stdio.h>#include<stdlib.h>#include<map>#include<string>#include<math.h>#include<stack>#include<algorithm>#include<queue>usi

2020-07-03 22:26:33 131

原创 PAT 1034&1114(并查集)

PAT1034(用了炒鸡多的map…) (:_」∠)#include <iostream>#include <stdio.h>#include<stdlib.h>#include <string.h>#include <algorithm>#include <vector>#include <unordered_map>#include <string.h>#include <map&g

2020-06-26 16:58:04 159

原创 PAT 1026 Table Tennis (30分)

蛮复杂的一道模拟题需要注意的点挺多的:1.优先级问题(vip桌子的安排)2.playtime规定在2h之内,超过2h按2h计算3.servingtime等于或大于21点的不输出#include <iostream>#include <stdio.h>#include<stdlib.h>#include <string>#include <algorithm>#include <vector>#include &lt

2020-06-22 22:00:31 133

原创 PAT 1089 Insert or Merge (25分)

#include <iostream>#include <stdio.h>#include <stdlib.h>#include <math.h>#include <string.h>#include <map>#include <algorithm>#include <vector>#include <queue>using namespace std;const int M

2020-06-04 18:11:31 92

原创 PAT 1090 Highest Price in Supply Chain (25分)

#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include <map>#include <string>#include <unordered_map>#include <queue>using

2020-06-04 18:04:27 104

原创 PAT 1091 Acute Stroke (30分)(做题记录)

In my code, I use a 2-D array to store L slices((n-1)*Mth-n*M-1th rows represent the nth slice)(I marked the point need to note in code).And at first I used dfs which leads to stack overflow so I use bfs to searth the graph and count quatity of connected

2020-06-04 14:01:02 93

原创 PAT 1088 Rational Arithmetic (20分)

Note:1.the format of output(be careful!!)2. find the greatest common divisor of numerator and the denominator3. simplify the result (like only have one minus sign of the minus number)#include <iostream>#include <stdio.h>#include<stdlib

2020-06-04 13:52:24 101

原创 PAT 1105 Spiral Matrix (25分)

In my submitted code,I simulate the process of filling the spiral matrix.Maybe there exists some simpler solution?#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <

2020-06-02 10:38:55 91

原创 PAT1106 Lowest Price in Supply Chain (25分)(做题记录)

BFS algorithm to find the shortest path from root to leaves and count the quatity of the paths.#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include

2020-06-02 10:32:55 149

原创 PAT1107 Social Clusters (30分)

In this question, I use tree structure to store set in array which have two operations: union and findroot.#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector&g

2020-06-02 10:30:32 154

原创 PAT1101 Quick Sort (25point(s))(做题记录)

Note:even the number is 0 we also have to cout<<endl in line2.(Or it can’t ac)(puzzling)#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include &

2020-05-31 18:47:19 152

原创 PAT 1102 Invert a Binary Tree (25point(s))(做题记录)

We just need to swap the left child and the right child of each node to invert the binary tree.#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include

2020-05-31 18:42:25 128

原创 PAT 1103 Integer Factorization (30point(s))

Recursion helps a lot.#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include <map>#include <string>#include <queue>#include <s

2020-05-31 18:39:32 109

原创 PAT 1132 Cut Integer (20point(s))(做题记录)

This question quzzled me a lot.Because in prevois code ,I wrote the function to count 1/2 digits’ quantity of a number as following,testcase 1 and 2 are wrong answer:int digit(int z){ int cnt = 0; int d=1; while (z/d>0) { d=d*10; ++cnt; }

2020-05-31 18:36:43 162 1

原创 PAT 1133Splitting A Linked List (25point(s))(做题记录)

Note :In some testcase,some nodes may not in the list ! So we can’t think the number of nodes in the list is N!Only can use -1 as the flag of the end of list.#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h&g

2020-05-31 18:12:35 182

原创 PAT 1134 Vertex Cover (25point(s))(做题记录)

#include <iostream>#include <stdio.h>#include<stdlib.h>#include <math.h>#include <algorithm>#include <vector>#include <map>#include <string>#include <unordered_map>#include <set>using n

2020-05-31 18:08:15 164

原创 PAT 1135 Is It A Red-Black Tree (30point(s))(做题记录)

Two days ago,I submitted the code but it wasn’t accepted.Then I spent a lot of time to change it and finally it ac!Note: the simple path in Property 5 means that path from each node to NULL! (that is the leaf!You can get this from property 3).In my previ

2020-05-31 11:37:16 292

原创 PAT 1104 Sum of Number Segments (20point(s))

To solve this question,we need to find the law of times of every number appears in all segments.Note: sum += num*(N - i)(i + 1);//if change it to sum+= (N - i)(i + 1)num,it can’t ac,because (N - i)(i + 1) would be a too big number to cause data overrun.

2020-05-30 23:07:27 222

原创 PAT 1139 First Contact (30point(s))(解题记录)

I don’t want to say more about this question…Note that the ID can be -0000!! So we should store ID in a string instead of int valid.I have no time to simply my code,so I’m sorry that it would be a little tedious.#include <iostream>#include <st

2020-05-27 23:14:12 273 1

原创 PAT 1138 Postorder Traversal (25point(s))(解题记录)

In this question,we need to print the first number of a tree’s postorder traversal sequence from its preorder and inorder traversal sequence.It’s not difficult to find that the number is the first leaf node when we traverse the tree(in root-leftchild-righ

2020-05-27 21:11:39 101

原创 1137 Final Grading (25point(s))(解题记录)

Define a struct stu ,store students’ information in a stu array(I use a map to find the student’s index in array according to their ID),and then sort the array based on the rules given in question.Last,print the list of students who are qualified for certi

2020-05-27 12:19:35 176

原创 PAT1136 A Delayed Palindrome (20point(s))(做题记录)

In my code,I use two char arrays to store the inpuet number and temporary results (like number’s reverse and the sum).bool isPali(char * N): judge if N is a palindromicvoid op(char N1,char N2):store the reverse of N1 and its reverse’s sum in N2(that’s

2020-05-27 11:19:23 232

原创 PAT1143 &1151 找LCA问题(刷题记录)

These two questions are similar.Both of them give traversal sequence of a binary tree and asks us to find the LCA(Lowest Common Ancestor) of some query pairs.

2020-05-26 17:47:53 144

原创 PAT 1142 Maximal Clique (25point(s))(刷题记录)

PAT 1142 Maximal Clique (25point(s))For convenience,I use adjacency matrix to store the undicrected graph.For each query,I use set to collect vertices,and when get a new vertice from cin, check if every vertice in the set is adjacent to the new one.If i

2020-05-26 16:32:05 142

原创 PAT 1141 PAT Ranking of Institutions (25point(s))(刷题记录)

This problem gives a list of PAT testees’ information including their ID,Score and school.We have to collect the institutions where they from,and output the ranklist of institutions in nondecreasing order of their ranks.My IdeaDefine a struct insti to s.

2020-05-25 21:58:40 216

原创 PAT 1140 Look-and-say Sequence (20point(s))(解题记录)

Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, …This problem asks to find the Nth Look-and-say sequence of a given digit.My IdeaThe main data structure I used is a queue Q that stores every temp.

2020-05-25 19:37:02 155

原创 PAT1145 Hashing - Average Search Time (25point(s)) (刷题笔记)

1145 Hashing - Average Search Time (25point(s))题目:把一个不同正整数组成的序列插入到一个哈希表中。然后从哈希表中找另一个给定的整数序列,并输出平均查找时间(the number of comparisons made to find whether or not the key is in the table)。哈希函数是 H(key)=key%TSize解决冲突的方式是二次探测,只用到正的增量。也就是说增量序列是1²,2²…(MSize-1)²,注

2020-05-25 17:11:32 152

空空如也

空空如也

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

TA关注的人

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