一层一层删 链表模拟 最开始写的是一个一个删的 WA #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<…
Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1043    Accepted Submission(s): 272 Problem Description Beerus needs to sort an array of N integers. Algorithms are not Beerus…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6215 题解:类似双链表的模拟. #include <iostream> #include <cstring> #include <cstdio> using namespace std; ; int a[M] , Next[M] , pre[M] , que[M]; int main() { int t; scanf("%d" , &t); wh…
http://acm.hdu.edu.cn/showproblem.php?pid=6215 题意:给出一个序列,对于每个数,它必须大于等于它前一个数,小于等于后一个数,如果不满足,就删去.然后继续去判断剩下的数,直到最后都满足. 思路: 建立双向链表,如果一个数是需要删除的,那么它只会影响它前一个的数和后一个的数,这样只需要把它前面的数保存下来,下次再跑即可. #include<iostream> #include<algorithm> #include<cstring&g…
题目链接 Problem Description Beerus needs to sort an array of N integers. Algorithms are not Beerus's strength. Destruction is what he excels. He can destroy all unsorted numbers in the array simultaneously. A number A[i] of the array is sorted if it sat…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6215 题意:给你长度为n的数组,定义已经排列过的串为:相邻两项a[i],a[i+1],满足a[i]<=a[i+1].我们每次对当前数组删除非排序过的串,合并剩下的串,继续删,直到排序完成. 解法:双向链表模拟过程,设置一个队列,用于存可能产生非排序过的串的头结点,每次从队列中拿出一个头结点判断后面的情况,若还能继续删除,则将头结点的上一个结点放入队列继续判,知道没有别的结点为止. #include…
Brute Force Sorting Time Limit: 1 Sec  Memory Limit: 128 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=6215 Description Beerus needs to sort an array of N integers. Algorithms are not Beerus's strength. Destruction is what he excels. He can destr…
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6215 题目: Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 496    Accepted Submission(s): 119 Problem Description Beerus need…
//================================================= // File Name : LinkQueue_demo //------------------------------------------------------------------------------ // Author : Common //类名:FirstLastList //属性: //方法: class FirstLastList_long{ private Lin…
单链表: insertFirst:在表头插入一个新的链接点,时间复杂度为O(1) deleteFirst:删除表头的链接点,时间复杂度为O(1) 有了这两个方法,就可以用单链表来实现一个栈了,见http://blog.csdn.net/a19881029/article/details/22579759 find:查找包含指定关键字的链接点,由于需要遍历查找,平均需要查找N/2次,即O(N) remove:删除包含指定关键字的链接点,由于需要遍历查找,平均需要查找N/2次,即O(N) publi…