首页
CALL1CE
取消

PAT-Favorite Color Stripe & Longest Symmetric String & 有向无环图的最长路 & 有向无环图固定终点的最长路

A1045 Favorite Color Stripe #include<iostream> #include<vector> using namespace std; //动规五部曲 //1.确认dp数组以及下标的含义 //以数组A[i]结尾的子序列,其最大长度为dp[i] //2.确定递推公式:如果i在序列中: dp[i] = max(1, dp[j] + 1...

晴问-关键路径长度 & 关键活动 & 关键路径

关键路径长度 #include<iostream> #include<vector> #include<stack> #include<queue> #include<cstdio> #include<cstring> using namespace std; const int maxn = 110; struct...

PAT-Hashing & Consecutive Factors & Come on! Let's C & A Delayed Palindrome

A1078 Hashing #include<iostream> #include<vector> #include<cstdio> #include<cmath> #include<unordered_map> using namespace std; const int maxn = 100000; bool primeTab...

PAT-Rational Arithmetic & Prime Factors

A1088 Rational Arithmetic #include<iostream> #include<vector> #include<cstdio> #include<string> using namespace std; typedef long long LL; vector<LL> numerator(2); ve...

PAT-Sum of Number Segments & Counting Ones & Rational Sum & Scanf()输入格式表

A1104 Sum of Number Segments #include<iostream> #include<vector> #include<cstdio> using namespace std; const int maxn = 100010; vector<long double> num(maxn); vector<lo...

PAT-LCA in a Binary Tree

A1151 LCA in a Binary Tree #include<iostream> #include<vector> #include<cstdio> using namespace std; const int maxn = 10010; vector<int> in(maxn); vector<int> pre(ma...

PAT-Heaps & Is It a Complete AVL Tree & Complete Binary Tree & Lowest Common Ancestor

A1147 Heaps #include<iostream> #include<vector> #include<cstdio> using namespace std; const int maxn = 1010; int n, m; vector<int> tree(maxn, -1); vector<int> post; ...

PAT-Online Map & Birds in Forest

A1111 Online Map #include<iostream> #include<vector> #include<cstdio> using namespace std; struct node { int v,len, time; node(int _v, int _len, int _time) : v(_v), len(_...

PAT-All Roads Lead to Rome & Topological Order & Family Property

A1087 All Roads Lead to Rome #include<iostream> #include<vector> #include<string> #include<unordered_map> using namespace std; //邻接表中需要存的数据: struct node { int v, cost;/...

PAT-Emergency & Gas Station

A1003 Emergency #include<iostream> #include<vector> #include<queue> using namespace std; struct node { int v, dis;//目标节点编号,距离 node(int _v, int _dis) :v(_v), dis(_dis) {} }; con...