Mac 蓝牙触控板(Magic trackpad)和原来自带的内建触控板同时使用

之前使用Magic trackpad 2时候出了点小问题,发现断开trackpad后依然无法使用内建触控板,导致自己用了一天的鼠标ORZ……然后就想到了能否两个触控板一起使用的功能……果然在辅助功能里面有~(不过似乎朋友的MacBook里这个功能是默认关闭的,不知道为什么我的是默认打开的…)

所以这个问题也可以解决:蓝牙触控板Magic trackpad断开连接后原触控板依然无法使用的问题

系统偏好设置 – 辅助功能 – 鼠标与触控板 – 取消勾选“有鼠标或无线触控板时忽略内建触控板”

PAT 1143. Lowest Common Ancestor (30) – 甲级

The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.
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 subtree of a node contains only nodes with keys greater than or equal to the node’s key.
Both the left and right subtrees must also be binary search trees.
Given any two nodes in a BST, you are supposed to find their LCA.
Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers: M (<= 1000), the number of pairs of nodes to be tested; and N (<= 10000), the number of keys in the BST, respectively. In the second line, N distinct integers are given as the preorder traversal sequence of the BST. Then M lines follow, each contains a pair of integer keys U and V. All the keys are in the range of int.
Output Specification:
For each given pair of U and V, print in a line “LCA of U and V is A.” if the LCA is found and A is the key. But if A is one of U and V, print “X is an ancestor of Y.” where X is A and Y is the other node. If U or V is not found in the BST, print in a line “ERROR: U is not found.” or “ERROR: V is not found.” or “ERROR: U and V are not found.”.
Sample Input:
6 8
6 3 1 2 5 4 8 7
2 5
8 7
1 9
12 -3
0 8
99 99
Sample Output:
LCA of 2 and 5 is 3.
8 is an ancestor of 7.
ERROR: 9 is not found.
ERROR: 12 and -3 are not found.
ERROR: 0 is not found.
ERROR: 99 and 99 are not found.

题目大意:给出一棵二叉搜索树的前序遍历,问结点u和v的共同最低祖先是谁~
分析:map<int, bool> mp用来标记树中所有出现过的结点,遍历一遍pre数组,将当前结点标记为a,如果u和v分别在a的左、右,或者u、v其中一个就是当前a,即(a >= u && a <= v) || (a >= v && a <= u),说明找到了这个共同最低祖先a,退出当前循环~最后根据要求输出结果即可~
PS:30分的题目30行代码解决,1行1分,惊不惊喜?意不意外?(真的是水题啊…)

PAT 1146. Topological Order (25) – 甲级

This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test each of the options.


Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N (<= 1,000), the number of vertices in the graph, and M (<= 10,000), the number of directed edges. Then M lines follow, each gives the start and the end vertices of an edge. The vertices are numbered from 1 to N. After the graph, there is another positive integer K (<= 100). Then K lines of query follow, each gives a permutation of all the vertices. All the numbers in a line are separated by a space.
Output Specification:
Print in a line all the indices of queries which correspond to “NOT a topological order”. The indices start from zero. All the numbers are separated by a space, and there must no extra space at the beginning or the end of the line. It is graranteed that there is at least one answer.
Sample Input:
6 8
1 2
1 3
5 2
5 4
2 3
2 6
3 4
6 4
5
1 5 2 3 6 4
5 1 2 6 3 4
5 1 2 3 6 4
5 2 1 6 3 4
1 2 3 4 5 6
Sample Output:
3 4

题目大意:给一个有向图,判断给定序列是否是拓扑序列~
分析:用邻接表v存储这个有向图,并将每个节点的入度保存在in数组中。对每一个要判断是否是拓扑序列的结点遍历,如果当前结点的入度不为0则表示不是拓扑序列,每次选中某个点后要将它所指向的所有结点的入度-1,最后根据是否出现过入度不为0的点决定是否要输出当前的编号i~flag是用来判断之前是否输出过现在是否要输出空格的~judge是用来判断是否是拓扑序列的~

Sublime Text 使用教程 整理笔记

【ps:以下快捷键以Mac上快捷键写】
Vim是一款跨平台编译器(再Linux、OS X和Windows下均可使用)
Vim和Sublime分别是命令行环境(CLI)和图形界面环境(GUI)下的最佳选择
编辑器面向无语义的纯文本,速度快体积小,适合编写单独的配置文件和动态语言脚本(Shell、Python、Ruby等)
IDE面向有语义的代码,适合编写静态语言项目(Java、C++和C#等)
用Vim编写Shell,用Sublime编写JS / HTML / Python
Package Control为了管理Sublime里面的插件而出现
打开命令版:Command + Shift + P(Win下把Command换成Ctrl)
购买需要 $70
使用Ctrl + `调出控制台(Console) 【mac下也是Ctrl】
Sublime使用JSON配置文件
Vim使用JKHL控制上下左右
不管光标在某行的什么位置,按Cmd + Enter会在当前行下面增加一行并跳转至该行,Shift + Cmd + Enter是在上面添加一行并跳转至该行
Shift + Ctrl + 左右箭头 逐词选择
Cmd + Shift + L将选中区域代码同时编辑,esc退出编辑
Cmd + J把选中区域合并成一行
有时候打开了很多标签页,用Cmd + P然后输入需要跳转的文件,输入文件名后Enter会跳转到该文件
使用Cmd + R输入函数名可以快速定位到类名或者函数名所在位置
使用F12快速跳转到当前光标所指的函数(或者类)名所定义的位置
对于Markdown的文件,Cmd + R会列出这个md文本的大纲
Ctrl + G输入行号会跳转到该行
Cmd + N新建一个标签页,Cmd + Shift + N新建一个文件并在新的窗口打开
Cmd + Shift + T恢复刚刚关闭的标签
Cmd + , 打开Sublime配置页面加入以下内容:
// 使光标闪动更加柔和
“caret_style”: “phase”,
// 高亮当前行
“highlight_line”: true,
// 高亮有修改的标签
“highlight_modified_tabs”: true,
Cmd + 【或者】当前行向左向右缩进
Cmd + Shift + V以当前粘贴光标所在处的缩进粘贴代码(放弃原代码的缩进方式)
使用Tab自动补全
Ctrl + M跳转到当前光标所指的括号匹配的那个括号处,Shift + Ctrl + M选中该匹配括号内所有内容

Mac 使用terminal/iterm/命令行 解压rar文件

使用homebrew安装rar(没安装homebrew的要先装一下下)

brew install caskroom/cask/rar

安装完成后先切到想要解压到的目录,然后使用解压功能:(xxx.rar是某个rar文件,要写它的路径在哪,可以直接从文件夹拖到命令行里面自动生成它的路径)

rar x xxx.rar

kindle iOS版 app 通过邮件导出笔记 “未设置电子邮箱账户”

近来出门都是ipad上用多看阅读、kindle、豆瓣阅读之类的app看电子书,多看的导出印象笔记功能不错,但是有的书多看阅读上没有,epub格式的也找不到(为了能够标注里面的文字做笔记),所以只能用kindle app看,结果发现导出笔记时候提示“未设置电子邮箱账户”,需要以下设置:

  1. 在app store里面把“邮件”这个系统自带app下载回来(之前拿到ipad第一天我为了极简将系统自带app都删了…只保留了上述三款阅读app…)
  2. 打开系统设置-账户与密码-添加账户(在此我添加了qq邮箱,注意邮箱密码不是qq密码也不是邮箱独立密码,是需要打开qq邮箱网页版,点击设置-账户-生成授权码-短信验证-发送短信“配置邮箱客户端”-生成的授权码填在密码框里面)
  3. 然后打开kindle app 笔记发送到邮箱时候就神奇的成功了……
  4. 导出的格式比较怪异,是html格式的但是可以复制文字,然而格式很丑还会奇怪的把标注的颜色也导出,emmmm谨慎选择……格式如下:

不过至少比豆瓣阅读app不能导出好多了……