pat

PAT甲级――A1032 Sharing

匿名 (未验证) 提交于 2019-12-02 23:49:02
loading being Figure 1 i Input Specification: Address Data Next where Address Data Next Output Specification: -1 Sample Input 1: 11111 22222 9 67890 i 00002 00010 a 12345 00003 g -1 12345 D 67890 00002 n 00003 22222 B 23456 11111 L 00001 23456 e 67890 00001 o 00010 Sample Output 1: 67890 Sample Input 2: 00001 00002 4 00001 a 10001 10001 s -1 00002 a 10002 10002 t -1 Sample Output 2: -1本以为,节点next出现两次,该节点就是公共节点,也包括-1在内,在牛客上测试通过,但在pat上测试失败,后来才感觉pat上可能出现公共节点在头结点上,故使用flag标记法,两条链表走过相同节点,则为公共节点 1 #include <iostream> 2 #include <unordered_map> 3 using namespace std; 4 int main() 5 { 6 int head1, head2

回文树学习笔记

匿名 (未验证) 提交于 2019-12-02 23:05:13
layout: post title: 回文树学习笔记 author: "luowentaoaa" catalog: true mathjax: true tags: - 回文树 首先,回文树有何功能? 假设我们有一个串S,S下标从0开始,则回文树能做到如下几点: 1.求串S前缀0~i内本质不同回文串的个数(两个串长度不同或者长度相同且至少有一个字符不同便是本质不同) 2.求串S内每一个本质不同回文串出现的次数 3.求串S内回文串的个数(其实就是1和2结合起来) 4.求以下标i结尾的回文串的个数 const int MAXN = 100005 ; const int N = 26 ; struct Palindromic_Tree { //cnt最后count一下之后是那个节点代表的回文串出现的次数 int next[MAXN][N] ;//next指针,next指针和字典树类似,指向的串为当前串两端加上同一个字符构成 int fail[MAXN] ;//fail指针,失配后跳转到fail指针指向的节点 int cnt[MAXN] ; //表示节点i表示的本质不同的串的个数(建树时求出的不是完全的,最后count()函数跑一遍以后才是正确的) int num[MAXN] ; //表示以节点i表示的最长回文串的最右端点为回文串结尾的回文串个数 int len[MAXN] ;//len

python五十六课――正则表达式(常用函数之findall)

匿名 (未验证) 提交于 2019-12-02 22:11:45
4).函数:findall(regex,string,[flags=0]):参数:和match、search一样理解功能:将所有匹配成功的子数据(子串),以列表的形式返回;如果一个都没有匹配成功,那么返回一个空列表compile()配合search()使用: pat=re.compile(r'www') matchobj=pat.search('www.sina.com!!www.baidu.com.com!!www') print(matchobj) 函数:findall(regex,string,[flags=0]):参数:和match、search一样理解功能:将所有匹配成功的子数据(子串),以列表的形式返回;如果一个都没有匹配成功,那么返回一个空列表 lt=re.findall(r'WWW','www.sina.com!!www.baidu.com!!www') lt=re.findall(r'WWW','www.sina.com!!www.baidu.com!!www',flags=re.I) print(lt,type(lt)) compile()配合findall()使用: pat=re.compile(r'www',flags=re.I) lt=pat.findall('www.sina.com!!www.baidu.com!!www') print(lt)

1141 PAT Ranking of Institutions PAT甲级

只谈情不闲聊 提交于 2019-12-01 04:49:14
After each PAT, the PAT Center will announce the ranking of institutions based on their students’ performances. Now you are asked to generate the ranklist. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (<=105), which is the number of testees. Then N lines follow, each gives the information of a testee in the following format: ID Score School where “ID” is a string of 6 characters with the first one representing the test level: “B” stands for the basic level, “A” the advanced level and “T” the top level; “Score” is an

pat

安稳与你 提交于 2019-11-30 13:26:17
基于端口的NAT Router 0: Router>enable Router#configure terminal Router(config)#interface fastEthernet 0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shutdown Router(config)#interface fastEthernet 0/1 Router(config-if)#ip address 192.168.2.1 255.255.255.0 Router(config-if)#no shutdown Router(config-if)#ip route 0.0.0.0 0.0.0.0 fastEther 0/1 Router(config)#access-list 1 permit any Router(config)#ip nat inside source list 1 interface fastEthernet 0/1 overload Router(config)#interface fastEthernet 0/1 Router(config-if)#ip nat outside Router(config-if)#interface

PAT 1003 我要通过! (20 分)

安稳与你 提交于 2019-11-30 03:34:21
“ 答案正确 ”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“ 答案正确 ”大派送 —— 只要读入的字符串满足下列条件,系统就输出“ 答案正确 ”,否则输出“ 答案错误 ”。 得到“ 答案正确 ”的条件是: 字符串中必须仅有 P 、 A 、 T 这三种字符,不可以包含其它字符; 任意形如 xPATx 的字符串都可以获得“ 答案正确 ”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串; 如果 aPbTc 是正确的,那么 aPbATca 也是正确的,其中 a 、 b 、 c 均或者是空字符串,或者是仅由字母 A 组成的字符串。 现在就请你为 PAT 写一个自动裁判程序,判定哪些字符串是可以获得“ 答案正确 ”的。 输入格式: 每个测试输入包含 1 个测试用例。第 1 行给出一个正整数 n (<10),是需要检测的字符串个数。接下来每个字符串占一行,字符串长度不超过 100,且不包含空格。 输出格式: 每个字符串的检测结果占一行,如果该字符串可以获得“ 答案正确 ”,则输出 YES ,否则输出 NO 。 输入样例: 8 PAT PAAT AAPATAA AAPAATAAAA xPATx PT Whatever APAAATAA 输出样例: YES YES YES YES NO NO NO NO 作者: CHEN, Yue 单位: 浙江大学 时间限制: 400

PAT 1093

我只是一个虾纸丫 提交于 2019-11-30 03:32:19
The string APPAPT contains two PAT 's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters. Now given any string, you are supposed to tell the number of PAT 's contained in the string. Input Specification: Each input file contains one test case. For each case, there is only one line giving a string of no more than 1 characters containing only P , A , or T . Output Specification: For each test case, print in one line the number of PAT 's contained in the string. Since the result may be a huge

[PAT]PAT使用Java解题时的注意点

天大地大妈咪最大 提交于 2019-11-29 20:25:10
在PAT的OJ系统上用Java解题时,需注意下面这些地方,否则都不知道错在哪里(第一次入坑好久没出来) 不要输入package名字 自己在本地调试的时候,可以在中间用System.out.print等输出语句调试,但是在PAT的OJ系统上,只有输出最终结果的时候,才可使用System.out.print等输出语句 类名必须为Main.否则出现编译错误,“class xxx.java is public,should be declared in a file named xxxx” 牛客网 PAT历年真题及模拟题在线编程练习 的 OJ会公开一些测试用例,方便排除bug,而PAT本身是没有公开测试用例的,有时侯根本不知道哪里错了 来源: CSDN 作者: 开发维护 链接: https://blog.csdn.net/zhouhuakang/article/details/49924483

4.7 其它高效技巧与算法

那年仲夏 提交于 2019-11-29 13:25:21
2019年9月PAT - 练习笔记——4.7 以下页码标注的是阅读器中实际页码,而不是书本身自印的页码。 第4章 入门篇(2)——算法初步 4.7 其它高效技巧与算法 注意 结果数为0时,可能要输出空行,见B1045 / A1101 题目没说的话,可以通过“格式错误”猜测 目录 B1040 / A1093 有几个PAT B1045 / A1101 快速排序 B1040 / A1093 有几个PAT 字符串 APPAPT 中包含了两个单词 PAT ,其中第一个 PAT 是第 2 位( P ),第 4 位( A ),第 6 位( T );第二个 PAT 是第 3 位( P ),第 4 位( A ),第 6 位( T )。 现给定字符串,问一共可以形成多少个 PAT ? 输入格式: 输入只有一行,包含一个字符串,长度不超过105,只包含 P 、 A 、 T 三种字母。 输出格式: 在一行中输出给定字符串中包含多少个 PAT 。由于结果可能比较大,只输出对 1000000007 取余数的结果。 输入样例: APPAPT 输出样例: 2 我的 #include <iostream> #include <string> using namespace std; const int MOD = 1000000007; int main(void) { string str = ""; cin >

PAT A1025 PAT Ranking(25)

半世苍凉 提交于 2019-11-29 03:51:50
题目描述 Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately after the test. Now it is your job to write a program to correctly merge all the ranklists and generate the final rank. 输入格式 Each input file contains one test case. For each case, the first line contains a positive number N (≤100), the number of test locations. Then N ranklists follow, each starts with a line containing a positive integer K (≤300), the number of