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 朝代:先秦 作者:屈原 原文: 帝高阳之苗裔兮,朕皇考曰伯庸.摄提贞于孟陬兮,惟庚寅吾以降.皇览揆余初度兮,肇锡余以嘉名:名余曰正则兮,字余曰灵均.纷吾既有此内美 ...
随机推荐
- MyBtis—原理及初始化
Mybatis的功能架构分为三层: 1) API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库.接口层 一接收到调用请求就会调用数据处理层来完成具体的数据处理. ...
- Flask Web 开发 错误页面自定义
如果要自定义错误画面,无法大多数情况是自定义404和500的情况 首先,要在路由中设置 通过app.error_handler这个装饰器来绑定响应函数 @main.errorhandler(404) ...
- FastDFS+Nginx分布式文件系统部署安装
安装: ##安装tracker.storage参考:http://www.cnblogs.com/zclzhao/p/5025229.html nginx代理设置参考:http://www.cnblo ...
- FromBottomToTop第十三周项目博客
FromBottomToTop第十三周项目博客 本周项目计划 完成游戏核心算法以及界面相关类和怪物类 项目进展 用户可选择游戏模式,共有20张不同的地图. 炮台的建立和升级. 小怪的路径算法. 参考资 ...
- Hexo搭建 github.io 静态博客使用指南
What? Hexo 是一个快速.简洁且高效的博客框架.可以使用markdown 解析成文章,在几秒内,即可利用靓丽的主题生成静态网页. Why? 笔记需要整理 How? github 创建 char ...
- Java加密代码 转换成Net版
java版本自己封装base64 package com.qhong; import java.io.UnsupportedEncodingException; import org.apache.c ...
- 'workspace' in VS Code
What is a 'workspace' in VS Code? You can save settings at the workspace level and you can open mult ...
- 【图片下载-代码】java下载网络图片资源例子
/** * @Description 下载网络图片资源 * @param imageUrl 图片地址 * @return String 下载后的地址 * @author SUNBIN * @date ...
- pickle & cPickle ValueError: unsupported pickle protocol: 3
pickle and cPickle pickle和cPickle是python对象的转储文件,保存的是python对象 他们分别是python2和python3的对应部分,建议引入的时候采用以下方法 ...
- 2015-9-13 NOIP模拟赛 by hzwer
好老的题了,但是还是很有做头的. 总结 不吸氧看来确实是没法用stl的啊(set常数太大了,开O2也没过) SPFA没认真学,觉得有堆优化Dijkstra就天下无敌了,今天负边权教我做人 于是苦逼的只 ...