- 博客(8)
- 资源 (1)
- 收藏
- 关注
转载 HRBUST - 2040 二叉树的遍历(由前序遍历和中序遍历推出后序遍历)
原题 #include #include using namespace std; int n, pre[110], in[110], post[110], cnt=0; int find(int ist, int ied, int target){ for(int i=ist; i<ied; i++) if(in[i]==target) return i; } void po
2017-07-29 10:41:02 268
原创 Ordering Tasks-简单的拓扑排序
原题在这里^_^ 题意:通过输入m条两任务间的优先顺序,输出一个可能的任务顺序; 思路;拓扑排序,就是建立一个图,每次选择入度为零的顶点,将与之关联的点的入度减一。 拓扑的关键两步骤: 1.入度为零的顶点输出; 2.将该点连得边去掉。(即与之关联点的入度减一) #include #include #include using namespace std; const int max
2017-07-26 08:37:04 357 1
原创 Oil Deposits
原题点这里 题意:算出一共多少块油田, 只要上下左右对角线相连就算一个。 思路:遍历每个点,只要是油田就以这个点深搜或者广搜, 将搜到的@变为 * ,每调用一次就+1. 深搜: #include #include #include using namespace std; const int maxn=1e2+10; char _map[maxn][maxn]; int m, n; int
2017-07-25 11:30:37 175
原创 Vessels
查看原题点这里^_^ D. Vessels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is a system of n vessels a
2017-07-23 21:44:15 354
原创 Passing the Message
题意:传信息,左边传给比自己矮的人中最高的那个,右边也是如此,输出每个人左右的被传递者,若左右没有比自己矮的人,输出0. 思路:维护一个从大到小的单调栈,最后一个被pop掉的元素是最大的。 #include #include #include using namespace std; #define maxn 50010 #define ll long long ll a[max
2017-07-22 20:54:36 249
原创 Stones(优先队列)
题意:奇数石头扔出去, 偶数石头忽略,相同位置的石头,先选择沉的,即能扔的距离比较近的。直到忽略最后一个为止,看一共走了多远。 思路:建一个优先队列,装进所有的元素,偶数石头pop掉,直到队列为空为止。 #include #include using namespace std; #define max 100000 struct stone{ int pos, dis; bool op
2017-07-22 20:19:37 269
原创 Arpa’s obvious problem and Mehrdad’s terrible solution
思路:此题考察了异或运算符,自己做的比较拙,用sign标记出现的数的次数,然后从头遍历,将x的两个异或因子的sign相乘, 加到pair里。 还有一种思路是一位大佬写的,用map从前往后记录与自己相异或的数字,如果后面出现了这个数字,那么就在总数中加上。 下面第一个是自己的代码,第二个是大佬的。 注:a^b=c => b=a^c; #include #include #define ll l
2017-07-22 19:29:01 180
原创 Codeforces 798A - Mike and palindrome
原题: Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. A palindrome is a string t
2017-07-09 18:17:49 486
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人