随笔分类 - 栈、队列
摘要:hdu-1896 问题描述:路上有一些石头(位置,所抛出的距离),如果遇到的是奇数块石头,则向前抛,偶数块石头就让它放在原地不管。如果遇到位置相同的两块石头,就假设抛出距离近的石头先遇到。 思路:遇到奇数块石头,(位置=位置+距离,距离)入栈,偶数则不管,直至栈空为止 #include <cstdi
阅读全文
摘要:/* num = q.top(); 其余同队列 定义: //priority_queue<int,vector<int>,less<int> > pque;//less<int> greater<int>后面不加括号 priority_queue<int,vector<int>,cmp> pque;
阅读全文
摘要:/*num = q.front() 取队顶元素 q.pop() 出队 q.push(num) 入队 q.empty() 判空 size = q.size() 大小 */ #include<iostream>#include<cstdio>#include<queue>using namespace
阅读全文
摘要:栈: /*num = s.top() 取栈顶元素 s.pop() 出栈 s.push(num) 入栈 s.empty() 判空 size = s.size() 大小 */ #include<iostream>#include<cstdio>#include<stack>using namespace
阅读全文
浙公网安备 33010602011771号