PAT-AL
文章平均质量分 83
X_空
这个作者很懒,什么都没留下…
展开
-
1154 Vertex Coloring vector pair int int v unordered_set int colors
//1154 Vertex Coloring (25 分)//#include <iostream>//#include <vector>//using namespace std;//const int MAXV = 10010;//const int INF = 1000000000;//int n, m, a, b, k;//vector<int...原创 2019-03-20 22:01:55 · 170 阅读 · 0 评论 -
PAT (Advanced Level)1109. Group Photo (25)
1109. Group Photo (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueFormation is very important when taking a group photo. Given the rules of forming K rows with N people as the following:...原创 2018-03-19 11:23:04 · 184 阅读 · 0 评论 -
PAT (Advanced Level)1029. Median (25)
题目链接1029. Median (25)时间限制1000 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven an increasing sequence S of N integers, the median is the number at the middle position. For example, the median o...原创 2018-03-05 23:00:17 · 104 阅读 · 0 评论 -
PAT (Advanced Level)1028. List Sorting (25)
题目链接1028. List Sorting (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueExcel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file ...原创 2018-03-05 21:06:28 · 112 阅读 · 0 评论 -
PAT (Advanced Level)1117. Eddington Number(25)
1117. Eddington Number(25)时间限制250 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueBritish astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defin...原创 2018-03-12 22:19:59 · 222 阅读 · 0 评论 -
PAT (Advanced Level)1118. Birds in Forest (25)&&1114. Family Property (25)并查集找爸爸
1114与1118为同一知识点,遂放在一起并查集知识点,没接触过。看到这道题真的思考了好久没有思路。网上查了大佬的解析和代码豁然开朗。当初在另外一本书上看见过并查集知识点,讲的云里雾里,太过于功力就放弃了。在网上看见了这版讲解,通俗易懂非常好。所以我认为并查集其实就是一个找爸爸的过程QAQ。以下为转载至上述连接的并查集内容话说江湖上散落着各式各样的大侠,有上千个之多。他们没有什么正当职业,整天背着...原创 2018-03-12 21:42:16 · 214 阅读 · 0 评论 -
PAT (Advanced Level)1107. Social Clusters (30)并查集
1107. Social Clusters (30)时间限制1000 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueWhen register on a social network, you are always asked to specify your hobbies in order to find some potential fri...原创 2018-03-19 09:14:47 · 105 阅读 · 0 评论 -
毕设前奏(java回顾)
package com.company;import java.util.*;import java.text.DateFormat;import java.text.SimpleDateFormat;public class Main { public static void print(int index,Object obj){ System.out....原创 2018-03-18 21:33:30 · 179 阅读 · 0 评论 -
前序和后序什么时候可以确定一棵树
一般情况下,已知二叉树的前序和后序是无法唯一确定一颗二叉树的,因为可能存在多种情况,即一个结点可能是根的左孩子也有可能是根的右孩子。前序的开始的第一个与后序的最后一个是相等的,这个结点就是根结点,以后序的根结点的前面一个结点作为参考,寻找这个结点在前序中的位置,如果这个位置的前一个位置的节点不是上一次遍历的前序序列中第一个起始节点,则部分唯一。递归进行下去,如果直到递归结束,上述条件持续成立,则该...原创 2018-03-12 16:49:53 · 6798 阅读 · 1 评论 -
PAT (Advanced Level)1120. Friend Numbers (20)
1120. Friend Numbers (20)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueTwo integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID"...原创 2018-03-12 15:11:04 · 122 阅读 · 0 评论 -
PAT (Advanced Level)1121. Damn Single (25)第二个测试点过不去,求助
1121. Damn Single (25)时间限制300 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, Yue"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alon...原创 2018-03-12 14:26:44 · 437 阅读 · 3 评论 -
PAT(Advanced Level)1004. Counting Leaves (30) 树的层次遍历
题目链接#include <iostream>#include <cstring>using namespace std;struct NODE { int father; int level; bool Nochild;};NODE v[100];char level[100] = "\0";int main() { int N, M, i, ...转载 2018-02-20 22:44:10 · 89 阅读 · 0 评论 -
PAT(Advanced Level)1005. Spell It Right (20) 栈 int转string
题目链接//1005. Spell It Right(20)#include <iostream>#include <cstring>#include <sstream>#include <stack>using namespace std;int main() { /*若第23行至29行代码替换为如下注释部分,则部分测试点错误,...原创 2018-02-20 23:50:13 · 99 阅读 · 0 评论 -
PAT (Advanced Level) 1007. Maximum Subsequence Sum (25) vector
题目链接时间复杂度为O(n^2)的算法://1007. Maximum Subsequence Sum(25)//O(n^2)算法#include<iostream>using namespace std;int main() { int K, i, j; int a[10001] = {}; int sum = 0; int start, end; int c...原创 2018-02-21 23:03:06 · 81 阅读 · 0 评论 -
PAT (Advanced Level)1010. Radix (25) 二分搜索
题目链接16分代码//1010. Radix(基数、根植、计数根)(25)#include <iostream>#include <cstring>#include <cmath>using namespace std;int main() { char N1[12], N2[12]; long long int tag, radix; ...原创 2018-02-23 19:58:43 · 100 阅读 · 0 评论 -
PAT (Advanced Level)1115. Counting Nodes in a BST (30)
1115. Counting Nodes in a BST (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The le...原创 2018-03-13 11:03:37 · 147 阅读 · 0 评论 -
PAT (Advanced Level)1113. Integer Set Partition (25)
1113. Integer Set Partition (25)时间限制150 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and ...原创 2018-03-13 14:40:22 · 116 阅读 · 0 评论 -
PAT (Advanced Level)1030. Travel Plan (30) dfs
题目链接1030. Travel Plan (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now ...原创 2018-03-06 15:18:58 · 80 阅读 · 0 评论 -
1153 Decode Registration Card of PAT
1153Decode Registration Card of PAT(25分)A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basi...原创 2019-03-13 22:02:41 · 162 阅读 · 0 评论 -
1152 Google Recruitment (20 分)
//1152 Google Recruitment :Find prime#include <cstdio>#include<string>#include<iostream>#include<vector>using namespace std;bool find(string a) { int b = stoi(a); int...原创 2019-02-11 21:36:49 · 434 阅读 · 2 评论 -
1141. PAT Ranking of Institutions (25)
1141. PAT Ranking of Institutions (25)时间限制500 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAfter each PAT, the PAT Center will announce the ranking of institutions based on their students' perfor...原创 2018-03-29 14:45:18 · 91 阅读 · 0 评论 -
1143. Lowest Common Ancestor (30)
1143. Lowest Common Ancestor (30)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as ...原创 2018-03-29 10:34:10 · 100 阅读 · 0 评论 -
1142. Maximal Clique (25)
1142. Maximal Clique (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueA clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjac...原创 2018-03-28 19:34:58 · 90 阅读 · 0 评论 -
1140. Look-and-say Sequence (20)
1140. Look-and-say Sequence (20)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueLook-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...wh...原创 2018-03-28 15:37:36 · 92 阅读 · 0 评论 -
1146. Topological Order (25)
1146. Topological Order (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThis is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order o...原创 2018-03-28 14:57:39 · 166 阅读 · 0 评论 -
树的遍历
// 树的遍历.cpp#include <iostream>#include <vector>using namespace std;vector<int>v, p, q, r;int m;void PostTraverse(int i) { if (i <= m) { PostTraverse(2 * i); PostTravers...原创 2018-03-27 21:20:54 · 92 阅读 · 0 评论 -
1147. Heaps (30)
1147. Heaps (30)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueIn computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node...原创 2018-03-27 20:46:34 · 94 阅读 · 0 评论 -
1104. Sum of Number Segments (20)
1104. Sum of Number Segments (20)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CAO, PengGiven a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, give...原创 2018-03-25 13:00:46 · 107 阅读 · 0 评论 -
1102. Invert a Binary Tree (25)
1102. Invert a Binary Tree (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), b...原创 2018-03-30 14:57:39 · 114 阅读 · 0 评论 -
1101. Quick Sort (25)
1101. Quick Sort (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CAO, PengThere is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one ...原创 2018-03-30 12:56:35 · 170 阅读 · 0 评论 -
PAT (Advanced Level)1031. Hello World for U (20)
题目链接1031. Hello World for U (20)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueGiven any string of N (>=5) characters, you are asked to form the characters into the shape of U. For examp...原创 2018-03-06 17:00:01 · 101 阅读 · 0 评论 -
PAT (Advanced Level) 1012. The Best Rank (25) struct vector sort
本文代码来源为此处//1012. The Best Rank(25)#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std;struct stu { int ID; int C; int M...原创 2018-02-25 16:24:50 · 186 阅读 · 0 评论 -
PAT (Advanced Level)1013. Battle Over Cities (25) DFS
题目链接//1013. Battle Over Cities(25)#include <iostream>#include <cstring> using namespace std;#define MAX 1001int edge[MAX][MAX];int visited[MAX];int N, M, K;void dfs(int node) {...原创 2018-02-25 21:40:30 · 110 阅读 · 0 评论 -
1123. Is It a Complete AVL Tree (30)(不会)
1123. Is It a Complete AVL Tree (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAn AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees ...原创 2018-03-12 11:13:50 · 149 阅读 · 0 评论 -
PAT (Advanced Level)1136. A Delayed Palindrome (20)
1136. A Delayed Palindrome (20)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueConsider a positive integer N written in standard notation with k+1 digits ai as ak...a1a0 with 0 <= ai <...原创 2018-03-08 21:27:19 · 120 阅读 · 0 评论 -
PAT(Advanced Level)1006. Sign In and Sign Out (25)
题目链接//1006. Sign In and Sign Out(25)#include <iostream>#include <cstring>using namespace std;int main() { char open_t[] = "23:59:59"; char close_t[] = "00:00:00"; int M; cin ...原创 2018-02-21 16:42:16 · 148 阅读 · 0 评论 -
PAT (Advanced Level)1139. First Contact (30)
题目链接1139. First Contact (30)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueUnlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early ye...原创 2018-03-08 13:45:17 · 362 阅读 · 0 评论 -
PAT(Advanced Level)1001. A+B Format (20)
题目连接//1001. A+B Format (20)#include <iostream>#include <string>#include <sstream>using namespace std;int main() { int a, b, k, count = 0, sub = 0; char p[30]; for (int i = ...原创 2018-02-17 23:51:08 · 114 阅读 · 0 评论 -
PAT(Advanced Level)1002. A+B for Polynomials (25)
题目连接//1002. A + B for Polynomials(25)#include <iostream>#include <algorithm>#include <iomanip>#include <string>using namespace std;int main() { int k, j, count = 0; f...原创 2018-02-17 23:49:33 · 113 阅读 · 0 评论 -
PAT (Advanced Level)1017. Queueing at Bank (25) 运算符的重载
题目链接1017. Queueing at Bank (25)时间限制400 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueSuppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the...原创 2018-02-27 23:37:40 · 130 阅读 · 0 评论