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 朝代:先秦 作者:屈原 原文: 帝高阳之苗裔兮,朕皇考曰伯庸.摄提贞于孟陬兮,惟庚寅吾以降.皇览揆余初度兮,肇锡余以嘉名:名余曰正则兮,字余曰灵均.纷吾既有此内美 ...
随机推荐
- Java基础教程:网络编程
Java基础教程:网络编程 基础 Socket与ServerSocket Socket又称"套接字",网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个s ...
- CentOS7 忘了root密码怎么办
今天打开很久没开机的另2台虚拟机,发现不记得root密码了. 于是参考了google搜索到的第一个答案,https://www.unixmen.com/reset-root-password-cent ...
- WdatePicker显示乱码
1.修改zh-cn.js内容: var $lang={ errAlertMsg: "不合法的日期格式或者日期超出限定范围,需要撤销吗?", aWeekStr: ["周&q ...
- fileupload上传文件时带参数
var userID = ""; $('#picture').fileupload({ url: "http://localhost:35708/Handler/File ...
- MySQL事务概述-1
事务是数据库区别于文件系统最重要的特性之一.事务可由一条非常简单的SQL语句组成,也可以由一组复杂的SQL语句组成.事务是访问并更新数据库中各种数据项的一个程序执行单元.在事务操作中,要么都做修改,要 ...
- 20145221 《Java程序设计》第二周学习总结
20145221 <Java程序设计>第二周学习总结 教材学习内容总结 第二周内容已在假期完成,详见博客: <Java程序设计>第三章-基础语法 代码调试中的问题和解决过程 第 ...
- Ubuntu 安装zookeeper
下载zookeeper Zookeeper下载 下载以后将文件迁移到/home/Hadoop/文件夹下面 hongdada@ubuntu:~/Downloads$ sudo mv zookeepe ...
- Using SQLXML Bulk Load in the .NET Environment
http://msdn.microsoft.com/en-us/library/ms171878.aspx 1.首先创建一张表 CREATE TABLE Ord ( OrderID ,) PRIMAR ...
- 安全之路:Web渗透技术及实战案例解析(第2版)
安全之路:Web渗透技术及实战案例解析(第2版)
- Python中通过多个字符分割(split)字符串的方法--转载
Python中字符串自带的split方法一次只能使用一个字符对字符串进行分割,但是python的正则模块则可以实现多个字符分割 import re re.split('_#|','this_is#a| ...