pat甲级真题分类
wsfhdhjs
这个作者很懒,什么都没留下…
展开
-
PAT(甲级)2019年春季考试
7-2 Anniversary#include<iostream>#include<set>using namespace std;const int maxn=100010;int n,m;set<string> s1,s2;int main(){ cin >> n; for(int i=0; i<n; i++) { string s; cin >> s;原创 2021-08-26 11:47:35 · 87 阅读 · 0 评论 -
pat甲级真题分类--双指针
Group Photo#include <iostream>#include <cstring>#include <cmath>#include <vector>#include <algorithm>using namespace std;const int MAX_N = 10010;const int MAX_K = 11;int group[MAX_K][MAX_N];struct People { cha原创 2021-08-11 15:04:08 · 106 阅读 · 0 评论 -
pat甲级真题分裂--并查集
1Birds in Forest #include<iostream>using namespace std;const int maxn=10010;int n,cnt;bool st[maxn];int birds[maxn],p[maxn];int find(int x){ if(x!=p[x]) p[x]=find(p[x]); return p[x];}int main(){ cin >> n;原创 2021-08-10 11:24:39 · 97 阅读 · 0 评论 -
pat甲级真题分类-树
Is It A Red-Black Tree/*判断一个树是否为红黑树:1.根节点是黑色2.节点是红色,左右儿子都是黑色3.从一个节点出发到叶子结点,其路径上黑色点的数量是相同的*/#include<iostream>#include<unordered_map>#include<cmath>#include<algorithm>using namespace std;const int maxn=33;int T;boo原创 2021-08-05 16:06:13 · 123 阅读 · 0 评论 -
pat甲级真题分类--图论
Vertex Cover#include<iostream>#include<cstring>using namespace std;const int maxn=10010;int n,m;bool st[maxn];struct node{ int a,b;}Node[maxn];int main(){ cin >> n >> m; for(int i=0; i<m; i++)原创 2021-08-05 11:13:13 · 116 阅读 · 0 评论 -
pat甲级真题分类--模拟链表
7-2 Block Reversing (25 分)Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the blocks in L. Fo原创 2021-07-19 15:15:07 · 138 阅读 · 0 评论 -
pat甲级真题分裂-迪杰斯特拉
7-4 Professional Ability Test (30 分)#include<cstdio>#include<queue>#include<string>#include<cstring>#include<unordered_set>/* 首先根据题目意思,这道题分成有环图和无环图,对于有环图来说,如果能直接得到考试,则直接输出directly, 对于其他情况,肯定每次都是从入度为0的点出发,首先找到整个路原创 2021-07-11 16:43:04 · 117 阅读 · 0 评论 -
pat甲级真题分类-数学问题
7-1 The Closest Fibonacci Number (20 分)#include<bits/stdc++.h>using namespace std;int num[1002]={0,1};int cnt=2;int main(){ int n; cin>>n; //读入一个n while(1) //死循环 { num[cnt]=num[cnt-1]+num[cnt-2]原创 2021-07-11 16:39:35 · 144 阅读 · 0 评论 -
pat甲级--根据中左,中后序遍历输出
7-3 Left-View of Binary Tree (25 分)The left-view of a binary tree is a list of nodes obtained by looking at the tree from left hand side and from top down. For example, given a tree shown by the figure, its left-view is { 1, 2, 3, 4, 5 }Given the inord..原创 2021-07-09 12:08:51 · 186 阅读 · 2 评论 -
pat甲级--水题
7-2 How Many Ways to Buy a Piece of Land (25 分)The land is for sale in CyberCity, and is divided into several pieces. Here it is assumed that each piece of land has exactly two neighboring pieces, except the first and the last that have only one. One can原创 2021-07-09 11:34:01 · 76 阅读 · 0 评论 -
pat甲级真题分类-dfs
7-4 Chemical 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原创 2021-07-04 11:36:40 · 353 阅读 · 0 评论 -
pat甲级真题分类-逻辑处理
7-3 File Path (25 分)The figure shows the tree view of directories in Windows File Explorer. When a file is selected, there is a file path shown in the above navigation bar. Now given a tree view of directories, your job is to print the file path for any原创 2021-07-04 11:14:54 · 259 阅读 · 1 评论 -
pat甲级真题分类--字符串处理
7-2 Subsequence in Substring (25 分)A substring is a continuous part of a string. A subsequence is the part of a string that might be continuous or not but the order of the elements is maintained. For example, given the string atpaaabpabtt, pabt is a subst原创 2021-07-04 11:13:41 · 162 阅读 · 0 评论 -
pat真题词汇积累
siblings 兄弟(siblings)节点ascending 上升的common difference(公差)原创 2021-07-04 07:33:03 · 101 阅读 · 0 评论 -
pat甲级真题分类--Floyd算法
给出任意两个点之间距离,用Floyd可以判断这个图是否是联通的,还能求出遍历这个图所需要的最短路径//题目的意思是给出任意两点之间的距离,如果这个图是联通的,则输出遍历的路径,并且输出遍历路径的距离;如果不是联通的,第1行输出正常的访问路径,第2行输出没访问过的点#include<iostream>#include<cstring>#include<vector>using namespace std;const int maxn=205;int e[m原创 2021-07-03 16:16:20 · 147 阅读 · 0 评论 -
pat甲级真题分类--大根堆
7-2 Lab Access Scheduling (25 分)Nowadays, we have to keep a safe social distance to stop the spread of virus due to the COVID-19 outbreak. Consequently, the access to a national lab is highly restricted. Everyone has to submit a request for lab use in adv原创 2021-07-03 15:18:53 · 181 阅读 · 0 评论 -
pat真题分类---贪心
2021春季7-2 Lab Access Scheduling//这道题完全等同于 最大不相交区间的数量 这不过这道题 (包含端点相交)#include<iostream>#include<algorithm>using namespace std;const int maxn=2010;struct node{ int l,r; bool operator<(const node &t)const { r原创 2021-07-03 11:53:45 · 94 阅读 · 0 评论