自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

克拉拉的博客

个人LEETCODE\PAT\OJ算法题解,知识见解

  • 博客(104)
  • 收藏
  • 关注

原创 不成型贪吃蛇

瞎写的试手,日后改进。#include<iostream>#include<queue>#include<map>#include<string>#include<cstring>#include<cstdio>#include<vector>#include<conio.h&am

2019-03-12 15:57:38 179

原创 PAT.A1018 Public Bike Management

There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the ...

2018-11-15 22:53:10 265

原创 PAT.A1072 Gas Station

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...

2018-11-15 14:22:06 222

原创 PAT.A1087 All Roads Lead to Rome

Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...

2018-11-14 17:20:31 186

原创 PAT.A1030 Travel Plan

A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...

2018-11-13 14:58:49 145

原创 PAT.A1003 Emergency

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...

2018-11-13 00:53:47 105

原创 PAT.A1013 Battle Over Cities

It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...

2018-11-11 01:49:15 118

原创 PAT.A1076 Forwards on Weibo

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a ...

2018-11-10 22:35:25 132

原创 PAT.A1034 Head of a Gang

One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t...

2018-11-07 23:56:45 132

原创 PAT.A1098 Insertion or Heap Sort

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...

2018-11-01 21:11:36 109

原创 一道考研题

第58题。数据输入换成数字,方便点,先建立二叉树再输出。 #include<iostream>#include<queue>using namespace std;struct node { int data; node* lchild; node* rchild;};const int maxn = 35;int pos[maxn];int ...

2018-10-31 23:24:27 179

原创 PAT.A1107 Social Clusters

When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of people who have some of thei...

2018-10-28 02:54:04 103

原创 PAT.A1066 Root of AVL Tree

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...

2018-10-26 18:33:56 101

原创 PAT.A1099 Build A Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right su...

2018-10-19 15:52:29 318

原创 PAT.A1064 Complete Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right su...

2018-10-19 15:25:00 138

原创 PAT.A1043 Is It a Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key. The right su...

2018-10-18 03:52:28 85

原创 PAT.A1004 Counting Leaves

A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts...

2018-10-12 04:06:33 114

原创 PAT.A1106 Lowest Price in Supply Chain

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on th...

2018-10-10 01:54:32 105

原创 PAT.A1094 The Largest Generation

 void bfs() { int level = 2, last = 1, first = 0, rear = 0, num = 0; queue<int> q; q.push(1); //l[1] = 1; rear++; lnum[1] = 1; while (!q.empty()) { int f = q.front(); q.pop(); fi...

2018-10-08 03:35:59 103

原创 PAT A1090 Highest Price in Supply Chain

#include<iostream>#include<cstdio>#include<algorithm>#include<cmath> #include<vector>#include<queue>#include<cstring>#include&am

2018-10-06 17:19:03 88

原创 PAT.1079 Total Sales of Supply Chain

#include<iostream>#include<cstdio>#include<algorithm>#include<cmath> #include<vector>#include<queue>#include<cstring>#include&am

2018-10-05 16:01:14 103

原创 PAT.A1053 Path of Equal Weight

 #include<iostream>#include<cstdio>#include<algorithm>#include<vector>#include<queue>#include<cstring>#include<stack>using namespace std;const int

2018-09-19 07:27:35 85

原创 PAT.A1102 Invert a Binary Tree

 The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your turn...

2018-09-14 06:14:39 96

原创 扩展二叉树

由于先序、中序和后序序列中的任一个都不能唯一确定一棵二叉树,所以对二叉树做如下处理,将二叉树的空结点用·补齐,如图所示。我们把这样处理后的二叉树称为原二叉树的扩展二叉树,扩展二叉树的先序和后序序列能唯一确定其二叉树。现给出扩展二叉树的先序序列,要求输出其中序和后序序列。【输入】扩展二叉树的先序序列。【输出】输出其中序和后序序列。【输入样例】ABD..EF..G..C....

2018-09-14 01:48:30 5139

原创 PAT.A1086 Tree Traversals Again

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac...

2018-09-05 21:08:32 84

原创 PAT.A1020Tree Traversals

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...

2018-09-01 22:08:52 153

原创 openjudge 3254:约瑟夫问题No.2 队列解法

总时间限制: 1000ms 内存限制: 65536kB描述n 个小孩围坐成一圈,并按顺时针编号为1,2,…,n,从编号为 p 的小孩顺时针依次报数,由1报到m ,当报到 m 时,该小孩从圈中出去,然后下一个再从1报数,当报到 m 时再出去。如此反复,直至所有的小孩都从圈中出去。请按出去的先后顺序输出小孩的编号。输入每行是用空格分开的三个整数,第一个是n,第二个是p,...

2018-08-07 21:10:38 418

原创 openjudge 2746:约瑟夫问题 循环链表解法

描述约瑟夫问题:有n只猴子,按顺时针方向围成一圈选大王(编号从1到n),从第1号开始报数,一直数到m,数到m的猴子退出圈外,剩下的猴子再接着从1开始报数。就这样,直到圈内只剩下一只猴子时,这个猴子就是猴王,编程求输入n,m后,输出最后猴王的编号。 输入每行是用空格分开的两个整数,第一个是 n, 第二个是 m ( 0 < m,n <=300)。最后一行是:0 0 输...

2018-08-05 21:59:29 1059

原创 openjudge 3254:约瑟夫问题No.2 循环链表解法

n 个小孩围坐成一圈,并按顺时针编号为1,2,…,n,从编号为 p 的小孩顺时针依次报数,由1报到m ,当报到 m 时,该小孩从圈中出去,然后下一个再从1报数,当报到 m 时再出去。如此反复,直至所有的小孩都从圈中出去。请按出去的先后顺序输出小孩的编号。输入每行是用空格分开的三个整数,第一个是n,第二个是p,第三个是m (0 < m,n < 300)。最后一行是:0 0 0...

2018-08-05 21:56:54 379

原创 openjudge 2812恼人的青蛙

#include <iostream>#include <algorithm>#include <cstdio>#include <cstdlib>using namespace std;int r,c,n;struct PLANT { int x,y;};PLANT plants[5001];PLANT plant;bool...

2018-08-04 16:55:46 482

原创 OPENJUDEG1813----熄灯问题

描述有一个由按钮组成的矩阵,其中每行有6个按钮,共5行。每个按钮的位置上有一盏灯。当按下一个按钮后,该按钮以及周围位置(上边、下边、左边、右边)的灯都会改变一次。即,如果灯原来是点亮的,就会被熄灭;如果灯原来是熄灭的,则会被点亮。在矩阵角上的按钮改变3盏灯的状态;在矩阵边上的按钮改变4盏灯的状态;其他的按钮改变5盏灯的状态。在上图中,左边矩阵中用X标记的按钮表示被按下,右边的矩阵表示灯状态的改...

2018-07-31 20:56:27 804

原创 PAT.A1091 Acute Stroke

#include<cstdio>#include<cstring>#include<vector>#include<algorithm>#include<iostream>#include<string>#include<set>#include<map>#includ

2018-07-29 17:46:47 113

原创 PAT.A1103 Integer Factorization

 #include<cstdio>#include<cstring>#include<vector>#include<algorithm>#include<iostream>#include<string>#include<set>#include<map>#inc

2018-07-28 02:15:30 140

原创 PAT.A1097 Deduplication on a Linked List

#include<cstdio>#include<cstring>#include<vector>#include<algorithm>#include<iostream>#include<string>#include<set>#include<map>#includ

2018-07-23 17:58:27 89

原创 PAT.A1074 Reversing Linked List

Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K = 3, then you must output 3→2→1→6→5→4; if K ...

2018-07-21 16:17:12 130

原创 PAT.A1052 Linked List Sorting

A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...

2018-07-17 21:58:11 159

原创 PAT.A1032 Sharing

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...

2018-07-14 22:07:13 155

原创 PAT.A1056 Mice and Rice

Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice...

2018-07-13 20:53:50 202

原创 PAT.A1051 Pop Sequence

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of t...

2018-07-11 03:34:54 146

原创 PAT.A1022 Digital Library

A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...

2018-07-06 05:20:22 100

空空如也

空空如也

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

TA关注的人

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