list 的翻转reverse源码: // 将链表倒置 // 其算法核心是历遍链表, 每次取出一个结点, 并插入到链表起始点 // 历遍完成后链表满足倒置 template <class T, class Alloc> void list<T, Alloc>::reverse() { if (node->next == node || link_type(node->next)->next == node) return; iterator first = beg…
Data Handler Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4286 Description You are in charge of data in a company, so you are called "Data Handler". Different from the data in computer, the data you have…
题意:有一串数字,两个指针,然后一些添加,删除,反转,以及移动操作,最后输出序列. 解法:可以splay做,但是其实双端队列更简便. 维护三个双端队列LE,MI,RI分别表示[L,R]序列左边,[L,R]这段区间的值和[L,R]右边的值.然后维护一个revd标记表示[L,R]内的数是否被翻转了,翻转了的话改变一下一些操作就行了.自己写一个pop_Front()和pop_Back()函数,分别取队首和队尾元素,然后队首或队尾pop掉. 代码: #include <iostream> #inclu…
splay 练手用: 杭电的oj要手动开栈: #include<cstdio> #pragma comment(linker, "/STACK:102400000,102400000") #include<cstring> #include<algorithm> #define inf 999999 #define maxn 1500009 #define lch(rt) son[rt][0] #define rch(rt) son[rt][1] u…
比赛链接: http://vjudge.net/contest/view.action?cid=47644#overview 比赛来源: 2012 ACM/ICPC Asia Regional Tianjin Online 果然我还是很受外界影响啊~~~这场打得好烂~~~ 155 / 175 Problem A HDU 4278 Faulty Odometer (水题, 简单的数位DP) 155 / 345 Problem B HDU 4279 Number  (打表找规律)   86 / 41…
题目描述 小$Y$是一个爱好旅行的$OIer$.她来到$X$国,打算将各个城市都玩一遍.小$Y$了解到,$X$国的$n$个城市之间有$m$条双向道路.每条双向道路连接两个城市.不存在两条连接同一对城市的道路,也不存在一条连接一个城市和它本身的道路.并且,从任意一个城市出发,通过这些道路都可以到达任意一个其他城市.小$Y$只能通过这些道路从一个城市前往另一个城市.小$Y$的旅行方案是这样的:任意选定一个城市作为起点,然后从起点开始,每次可以选择一条与当前城市相连的道路,走向一个没有去过的城市,或者…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1062 解题报告:注意一行的末尾可能是空格,还有记得getchar()吃回车符. #include<cstdio> #include<string.h> #include<iostream> #include<algorithm> #include<cmath> #include<deque> #include<cstdlib>…
Text Reverse                                                                                  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Ignatius likes to write words in reverse way. Given…
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the inpu…
Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 24157    Accepted Submission(s): 9311 Problem Description Ignatius likes to write words in reverse way. Given a single line of text…