- 博客(6)
- 收藏
- 关注
原创 1155 Heap Paths (30分)
比较简单。。。。考试要是都考这样的100分真的是轻轻松松。。 #include<iostream> #include<vector> using namespace std; int n; vector<vector<int>> ans; vector<int> temp; bool checkmax(vector<int>...
2020-02-28 17:40:30
153
原创 1154 Vertex Coloring (25分)
题目意思就是说要求判断给的图里每个相邻点的颜色是不是有相同的,没有的话输出颜色的数目,否则输出NO,读懂了题意就不难。 #include<iostream> #include<vector> #include<set> using namespace std; int n, m,v1,v2,k,color[10005]; vector<pair<in...
2020-02-28 17:09:41
183
原创 1151 LCA in a Binary Tree (30分)
不用建树!不用建树!!基本上碰到求LCA的都可以这么做出来。 #include<iostream> #include<vector> #include<map> #include<algorithm> using namespace std; int m, n,temp,u,v; int main() { cin >> m >&g...
2020-02-28 13:54:40
204
原创 1138 Postorder Traversal (25分)
因为数组可能过大而且我们只需要输出第一个,所以我们可以截取左边的部分,后面的就不用考虑了(注意根只有右孩子的情况,可以把根舍去,把原根的右孩子作为根) #include<iostream> #include<vector> using namespace std; int n; vector<int> pre, in; bool flag; void trave...
2020-02-26 19:42:03
175
原创 1131 Subway Map (30分) 自叹弗如
还是深度搜索吧,参考了柳婼大神的代码(永远的神),反正一开始我是一点头绪都没有的(智商真的不够用啊)。不过深度搜索按理说运算数量级是比较大的,对于多次查询来说的时间应该不够才对。。。还有就是对处理中转站的问题,就是对边的处理,每个边都标记好属于哪条线路,输出的时候遇到线路不一样就输出一次,以上。 #include<iostream> #include<vector> usi...
2020-02-25 17:37:58
152
原创 1123 Is It a Complete AVL Tree (30分)
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<vector> using namespace std; int n, temp,cnt; bool flag; struct node { int value,height;...
2020-02-24 17:42:28
252
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅