test20181024 qu
题意

分析
极似UVa11995 I Can Guess the Data Structure!
模拟即可,时间复杂度(……)\(O(n \log n)\)
旁边的L君:这题有两个坑点,我被卡了一次。
然而我一次就AC了。
旁边的L君:一个坑点是空栈,一个是输出格式
代码
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<complex>
#include<cassert>
#define rg register
#define il inline
#define co const
#pragma GCC optimize ("O0")
using namespace std;
template<class T> il T read()
{
T data=0;
int w=1;
char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-')
w=-1;
ch=getchar();
}
while(isdigit(ch))
data=10*data+ch-'0',ch=getchar();
return data*w;
}
template<class T> il T read(T&x)
{
return x=read<T>();
}
typedef long long ll;
const int INF=0x7fffffff;
stack<int>S;
queue<int>Q;
priority_queue<int>H;
int main()
{
freopen("qu.in","r",stdin);
freopen("qu.out","w",stdout);
int n=read<int>();
bool is=1,iq=1,ih=1;
for(int i=1;i<=n;++i)
{
int opt=read<int>(),v=read<int>();
if(opt==1)
{
if(is)
{
S.push(v);
}
if(iq)
{
Q.push(v);
}
if(ih)
{
H.push(v);
}
}
else
{
if(is)
{
if(S.empty())
is=0;
else if(S.top()!=v)
is=0;
else
S.pop();
}
if(iq)
{
if(Q.empty())
iq=0;
else if(Q.front()!=v)
iq=0;
else
Q.pop();
}
if(ih)
{
if(H.empty())
ih=0;
else if(H.top()!=v)
ih=0;
else
H.pop();
}
}
}
printf("%s\n",is?"YES":"No");
printf("%s\n",iq?"YES":"No");
printf("%s\n",ih?"YES":"No");
// fclose(stdin);
// fclose(stdout);
return 0;
}
test20181024 qu的更多相关文章
- 12563 Jin Ge Jin Qu hao
• Don’t sing a song more than once (including Jin Ge Jin Qu). • For each song of length t, either si ...
- UVA12563-Jin Ge Jin Qu hao(动态规划基础)
Problem UVA12563-Jin Ge Jin Qu hao Accept: 642 Submit: 7638Time Limit: 3000 mSec Problem Descriptio ...
- uVa 12563 Jin Ge Jin Qu
分析可知,虽然t<109,但是总曲目时间大于t,实际上t不会超过180*n+678.此问题涉及到两个目标信息,首先要求曲目数量最多,在此基础上要求所唱的时间尽量长.可以定义 状态dp[i][j] ...
- UVA - 12563 Jin Ge Jin Qu hao (01背包)
InputThe first line contains the number of test cases T (T ≤ 100). Each test case begins with two po ...
- hanzi 全拼音 qu de
Function pinyin(ByVal mystr As String, Optional types As Byte = 0) As StringDim temp As String, i ...
- UVA Jin Ge Jin Qu hao 12563
Jin Ge Jin Qu hao (If you smiled when you see the title, this problem is for you ^_^) For those who ...
- 12563 - Jin Ge Jin Qu hao——[DP递推]
(If you smiled when you see the title, this problem is for you ^_^) For those who don’t know KTV, se ...
- UVA12563Jin Ge Jin Qu hao(01背包)
紫书P274 题意:输入N首歌曲和最后剩余的时间t,问在保证能唱的歌曲数目最多的情况下,时间最长:最后必唱<劲歌金曲> 所以就在最后一秒唱劲歌金曲就ok了,背包容量是t-1,来装前面的歌曲 ...
- qu
离骚 (3481人评分) 8.5 朝代:先秦 作者:屈原 原文: 帝高阳之苗裔兮,朕皇考曰伯庸.摄提贞于孟陬兮,惟庚寅吾以降.皇览揆余初度兮,肇锡余以嘉名:名余曰正则兮,字余曰灵均.纷吾既有此内美 ...
随机推荐
- C#反射——简单反射操作类的封装
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Re ...
- python中小数点后取2位(四舍五入)以及取2位(四舍五不入)
一.小数点后取2位(四舍五入)的方法方法一:round()函数其实这个方法不推荐大家使用,查询资料发现里面的坑其实很多,python2和python3里面的坑还不太一样,在此简单描述一下python3 ...
- Django使用本地css/js文件
Django使用本地css/js文件 在manager.py同层级下创建static文件夹, 里面放上css , js, images等文件或者文件夹 我的文件夹层级 然后只需在settings.py ...
- 20145333《网络对抗》Exp2 后门原理与实践
20145333<网络对抗>Exp2 后门原理与实践 1.基础问题回答 (1)例举你能想到的一个后门进入到你系统中的可能方式? 通过邮件发送,邮箱里经常受到一些陌生人发来的链接. 误入了一 ...
- Git-标签管理【转】
本文转载自:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 标签管理 发布一个版本 ...
- [POJ2625][UVA10288]Coupons
Description Coupons in cereal boxes are numbered 1 to n, and a set of one of each is required for a ...
- python 获取列表大于指定长度的元素
def long_words(n, str): word_len = [] txt = str.split(" ") for x in txt: if len(x) > n: ...
- ng-grid
请查看官网:http://angular-ui.github.io/ui-grid/ 简单的使用: 总的来说我们 1.需要引入ng-grid-1.3.2.js 2.在html页面需要加入 class ...
- Vue.js的类Class 与属性 Style如何绑定
Vue.js的类Class 与属性 Style如何绑定 一.总结 一句话总结:数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是属性,我们可以用 v-bind 处理它们:我 ...
- 网络编程 单机最大tcp连接数
在tcp应用中,server事先在某个固定端口监听,client主动发起连接,经过三路握手后建立tcp连接.那么对单机,其最大并发tcp连接数是多少? 如何标识一个TCP连接 在确定最大连接数之前,先 ...