搞一个栈模拟即可。对比一下和一年前考场上的代码233

//2018.11.8
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 110
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<''||c>'')) c=getchar();return c;}
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
int getlim()
{
char c=getc();
if (c=='n') return ;
else
{
int l=c^,c=getchar();
if (c>=''&&c<='') l=l*+(c^);
return l;
}
}
int T,top;
bool isenter[N],isconst[N],isappear[];
char var[N];
int main()
{
T=read();
while (T--)
{
memset(isappear,,sizeof(isappear));top=;
int n=read();getc();
char c=getc();int p;
if (c=='') p=;else p=read();
bool iserr=;int cnt=,ans=,isout=;
while (n--)
{
c=getc();
if (c=='F')
{
char v=getc();
if (isappear[v]) iserr=;
int l=getlim(),r=getlim();
if (!iserr)
{
var[++top]=v;isappear[v]=;
isconst[top]=r-l<=;
isenter[top]=r>=l;
if (!isout) ans=max(ans,cnt+=isconst[top]^);
isout+=isenter[top]^;
}
}
else
{
if (top==) iserr=;
if (!iserr)
{
isout-=isenter[top]^;
if (!isout) cnt-=isconst[top]^;
isappear[var[top]]=;
top--;
}
}
}
if (top!=) iserr=;
if (iserr) cout<<"ERR"<<endl;
else if (ans==p) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return ;
}
//2017.11.11
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int t,n,w,top;
bool flag=,a[],ifn[],ifcmp[];
char stk[];
int main()
{
cin>>t;
while (t>)
{
t--;
cin>>n;
char c=getchar();
while ((c<''||c>'')&&(c!='n')) c=getchar();
//cout<<c<<endl;
if (c=='') w=;
else
{
c=getchar();
cin>>w;
}
//cout<<w<<endl;
c=getchar();
top=;
memset(a,,sizeof(a));
memset(ifcmp,,sizeof(ifcmp));
flag=;
int o=,MAX=,iflr=;
for (int i=;i<=n;i++)
{
c=getchar();while (c!='E'&&c!='F') c=getchar();
if (c=='E')
{
if (top<=) flag=;
else
{
a[stk[top]]=;
if (ifn[top]) o--;
if (ifcmp[top]) iflr--;
top--;
}
}
else
{
char x;int l,r;
cin>>x;char tmp=x;
if (a[x]) flag=;
else
{
a[x]=;
cin>>x;
if (x=='n') l=;
else
{
l=x-;
x=getchar();
if (x>=''&&x<='') l=l*+x-;
}
cin>>x;
if (x=='n') r=;
else
{
r=x-;
x=getchar();
if (x>=''&&x<='') r=r*+x-;
}
if (l>r)
{
top++;
stk[top]=tmp;
ifn[top]=;
ifcmp[top]=;
iflr++;
}
else if(l<&&r<||l==r)
{
top++;
stk[top]=tmp;
ifn[top]=;
ifcmp[top]=;
}
else
{
top++;
stk[top]=tmp;
if (iflr) ifn[top]=;
else
{
ifn[top]=;
o++;
if (o>MAX) MAX=o;
}
ifcmp[top]=;
}
}
}
}
if (top>) flag=;
if (!flag) cout<<"ERR"<<endl;
else
{
if (MAX==w) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return ;
}

Luogu3952 NOIP2017时间复杂度的更多相关文章

  1. 【比赛】NOIP2017 时间复杂度

    恶心的模拟题,考场上犯了一堆错误,多组数据清空没清完.数组开小...民间都是50分,结果CCF90.. 考完后随便改改就过了,还好只少了10分,如果真的是50,我估计会疯掉. 因为考场的时候没写好,所 ...

  2. [Luogu 3952] NOIP2017 时间复杂度

    [Luogu 3952] NOIP2017 时间复杂度 一年的时间说长不长,说短,也不短. 一年之内无数次觉得难得可怕的题目,原来也就模拟这么回事儿. #include <cstdio> ...

  3. P3952 NOIP2017 时间复杂度

    写了两三个小时,麻烦倒是不麻烦,要考虑清楚,想全了 只过了样例提交是不是傻,要自己造数据 数据不大可以用STL 建议自己刚一下,不看代码 #include <iostream> #incl ...

  4. luoguP3952 [NOIP2017]时间复杂度 模拟

    原本只是想看下多久能码完时间复杂度 然后在30min内就码完了,然后一A了???? 首先,这题完全可以离线做 我们先把所有的操作读完,判断合不合法之后,再去判断和标准答案的关系 具体而言 把所有的操作 ...

  5. [NOIP2017]时间复杂度

    题目描述 小明正在学习一种新的编程语言 A++,刚学会循环语句的他激动地写了好多程序并 给出了他自己算出的时间复杂度,可他的编程老师实在不想一个一个检查小明的程序, 于是你的机会来啦!下面请你编写程序 ...

  6. 【洛谷P3952】[NOIP2017]时间复杂度

    时间复杂度 题目链接 对于 100%的数据:L≤100 . 很明显的模拟题 然而考试时还是爆炸了.. 调了一下午.. 蒟蒻表示不会离线操作.. 直接贴代码: #include<cstdio> ...

  7. NOIP2017 时间复杂度 大模拟

    再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...

  8. 【题解】NOIP2017时间复杂度

    对大模拟抱有深深的恐惧……不过这次写好像还好?拿个栈维护一下循环的嵌套,然后重定义一下读入即可.记得去年在考场上面死活调不粗来,代码也奇丑无比……希望今年能好一点吧! #include <bit ...

  9. [NOIP2017]时间复杂度(模拟)

    sscanf读入数字,getline(cin,string)读一整行,其余暴力模拟即可. #include<cstdio> #include<string> #include& ...

随机推荐

  1. 微信小程序navigator无法跳转情况

    情况有三种 跳转的页面没有在app.json中注册 跳转的路径不正确 以上两种在命令行(console)中都会提示 跳转的页面在TabBar中,需要将open-type属性是设置为switchTab

  2. checked="checked"无效,radio未选中问题排查

    在使用attr给元素设置属性的时候,但是显示在页面就是未选中,而且是只使用一两次是ok的,但是连着多使用就不起作用了,百度了下,发现遇到这个问题的人还蛮多的, 有人说,发现在jQuery1.6版本之后 ...

  3. springmvc重定向请求。

    SpringMVC重定向传参数的实现(来自网友) 验证了我说的,从model层中拿来的数据,不管什么类型,都是通过隐含模型,中转,放入request中的.除非你特意把这些数据放到session域中. ...

  4. 深度解析JQuery Dom元素操作技巧

    深度解析JQuery Dom元素操作技巧 DOM是一种与浏览器.平台.语言无关的接口,使用该接口可以轻松访问页面中所有的标准组件,这篇文章给大家介绍了JQuery dom元素操作方法,写的十分的全面细 ...

  5. SVN 命令整理

    1.将文件checkout到本地目录 svn checkout path(path是服务器上的目录) 例如:svn checkout svn://192.168.1.35/pro/domain 如果开 ...

  6. Test类实验

    package PC_TEST; class CPU{ int speed; CPU(){ speed=0; } CPU(int k){ speed=k; } void setSpeed(int k) ...

  7. Android 数据库 ANR的例子

    android 开启事务之后,在其他线程是不能进行增删改查操作的.例子如下: 首先,一个线程里面去开启事务,里面对数据库的任何操作都没有. DBAdapter.getInstance().beginT ...

  8. anaconda虚拟环境操作

    1.首先在所在系统中安装Anaconda.可以打开命令行输入conda -V检验是否安装以及当前conda的版本. 2.conda常用的命令. 1)conda list 查看安装了哪些包. 2)con ...

  9. C#属性默认值设置

    关于在MVC中view中设置默认值,可以象如下设置: 1.关于VIEWMODEL的部分 如果是C#  6.0,网上资料查到说可以 如果语法不支持,只能改回.net 2.0的写法. public cla ...

  10. goroutine 并发之搜索文件内容

    golang并发编程 - 例子解析 February 26, 2013 最近在看<Programming in Go>, 其中关于并发编程写得很不错, 受益非浅, 其中有一些例子是需要多思 ...