随笔分类 -  紫书第六章习题

摘要:这个题的第二组数据一直过不了,原因是int layer=t.layer写在了for的外面,导致每一个方向共用了一个layer。/*InputThe input consists of several data sets. The first line of the i... 阅读全文
posted @ 2018-05-02 21:06 MCQ 阅读(104) 评论(0) 推荐(0)
摘要:/*Sample Inpute2 e4a1 b2b2 c3a1 h8a1 h7h8 a1b1 c3f6 f6Sample OutputTo get from e2 to e4 takes 2 knight moves.To get from a1 to b2 take... 阅读全文
posted @ 2018-05-02 17:31 MCQ 阅读(105) 评论(0) 推荐(0)
摘要:#includeusing namespace std;typedef struct node * tree;typedef struct node{ tree rchild; tree lchild; char data;}node;tree df... 阅读全文
posted @ 2018-05-02 15:35 MCQ 阅读(94) 评论(0) 推荐(0)
摘要:学到了cin.get()清除输入流的换行符和getline(cin,s)获取一行的输入。#includeusing namespace std;int main(){ int t; cin>>t; cin.get(); while(t--) ... 阅读全文
posted @ 2018-04-30 14:09 MCQ 阅读(82) 评论(0) 推荐(0)
摘要:这一题是典型的欧拉道路题目。 欧拉道路的定义是: 除了起点和终点外, 其他点的“进出” 次数应该相等。 换句话说,除了起点和终点外, 其他点的度数应该是偶数。对于有向图, 则必须其中一个点的出度恰好比入度大1, 另一个的入度比出度大。如果奇点数不存在的话, 则可以从... 阅读全文
posted @ 2018-04-30 11:34 MCQ 阅读(279) 评论(3) 推荐(0)
摘要:拓扑排序水题,但因为没做好邻接阵的初始化导致WA了几发,以后一定要注意初始化!!!#includeusing namespace std;#define maxn 1000vector G[maxn];int in[maxn]; //入度int t... 阅读全文
posted @ 2018-04-30 09:07 MCQ 阅读(111) 评论(0) 推荐(0)
摘要:dfs+查过的做记号/*ample Input1 1*3 5*@*@***@***@*@*1 8@@****@*5 5****@*@@*@*@**@@@@*@@@**@0 0Sample Output0122 */#include #includeusing name... 阅读全文
posted @ 2018-04-26 00:35 MCQ 阅读(83) 评论(0) 推荐(0)
摘要:/*The input contains multiple test cases, each describing a single tree. A tree is specified by giving thevalue in the root node, foll... 阅读全文
posted @ 2018-04-21 15:56 MCQ 阅读(85) 评论(0) 推荐(0)
摘要:递归求解 非常巧妙/*The input begins with a single positive integer on a line by itself indicating the numberof the cases following, each of th... 阅读全文
posted @ 2018-04-21 10:28 MCQ 阅读(103) 评论(0) 推荐(0)
摘要:给下落的深度和小球个数,小球依次下落,结点有个开关,每到一个结点,开关关向左,开向右一开始想到了简单模拟,结果超时…[cpp] view plain copy#include #include #include #define maxn 20 usin... 阅读全文
posted @ 2018-04-19 16:27 MCQ 阅读(145) 评论(0) 推荐(0)
摘要:数组模拟链表#include#include#includeusing namespace std;const int maxn =1000000+5;int last,cur,nex[maxn];char s[maxn];int main(){ while(c... 阅读全文
posted @ 2018-04-17 13:11 MCQ 阅读(65) 评论(0) 推荐(0)
摘要:/*Sample Input9A 50 10B 10 20C 20 5D 30 35E 35 15F 15 5G 5 10H 10 20I 20 25ABC(AA)(AB)(AC)(A(BC))((AB)C)(((((DE)F)G)H)I)(D(E(F(G(HI)))... 阅读全文
posted @ 2018-04-17 00:21 MCQ 阅读(100) 评论(0) 推荐(0)