搞一个栈模拟即可。对比一下和一年前考场上的代码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. NC使用技巧

    1. NC 1.1概述 1.1.1 优点: 1)网络工具中的瑞士军刀 2)侦听模式/传输模式. 3)可代替telnet获取banner信息. 4)传输文件/目录. 5)传输文本信息. 6)加密传输文件 ...

  2. 【rip-基础配置】

    配置rip,默认rip  id为 1:rip有version1和version2两个版本;宣告与rip直连的网段; 优化rip: [interface_name] rip poison-reverse ...

  3. css表格

    今天写某个平台的前端数据展示 主要使用表格展示 正好复习总结一下css的表格 首先说说thead.tbody.tfoot <thead></thead> <tbody&g ...

  4. jQuery(四)--HTTP请求

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. laravel框架excel 的导入导出功能

      1.简介 Laravel Excel 在 Laravel 5 中集成 PHPOffice 套件中的 PHPExcel,从而方便我们以优雅的.富有表现力的代码实现Excel/CSV文件的导入和导出. ...

  6. PHP中的面向对象魔术方法大全

    1.__construct  构造方法 2.__destruct  析构方法 3.__get 获取成员值 4.__set 设定成员值 5.__isset 判断成员值 6.__unset unset成员 ...

  7. [拉格朗日反演][FFT][NTT][多项式大全]详解

    1.多项式的两种表示法 1.系数表示法 我们最常用的多项式表示法就是系数表示法,一个次数界为\(n\)的多项式\(S(x)\)可以用一个向量\(s=(s_0,s_1,s_2,\cdots,s_n-1) ...

  8. 46-Identity MVC:登录逻辑实现

    1- Login.cshtml <h3>Login</h3> @model MvcCookieAuthSample.ViewModel.LoginViewModel <d ...

  9. Python:正则表达式—— re 模块

    一.什么是正则表达式(Regular Expression) 正则表达式本身是一种小型的.高度专业化的编程语言,它内嵌在Python中,并通过 re(regular expression)模块实现.使 ...

  10. 「暑期训练」「基础DP」FATE(HDU-2159)

    题意与分析 学习本题的时候遇到了一定的困难.看了题解才知道这是二重背包.本题的实质是二重完全背包.二维费用的背包问题是指:对于每件物品,具有两种不同的费用,选择这件物品必须同时付出这两种代价:对于每种 ...