【比赛】NOIP2017 时间复杂度
恶心的模拟题,考场上犯了一堆错误,多组数据清空没清完、数组开小。。。民间都是50分,结果CCF90。。
考完后随便改改就过了,还好只少了10分,如果真的是50,我估计会疯掉。
因为考场的时候没写好,所以最终的代码也很难看。
- #include<bits/stdc++.h>
- using namespace std;
- int T,n,stk[],p[],fnum,stack_num,sck[],sck_num;
- char s[],ch[],res[];
- inline void init()
- {
- memset(p,,sizeof(p));
- memset(res,,sizeof(res));
- memset(sck,,sizeof(sck));
- memset(stk,,sizeof(stk));
- sck_num=;
- stack_num=;
- fnum=;
- }
- inline void Dealwith()
- {
- init();
- int ans=,mark=,nxt=,nnum=,las=,done=;
- for(register int i=;i<=n;++i)
- {
- scanf("%s",ch);
- if(ch[]=='F')
- {
- if(done)
- {
- scanf("%s",ch);
- scanf("%s",ch);
- scanf("%s",ch);
- continue;
- }
- fnum++;
- scanf("%s",ch);
- if(p[ch[]-'a'])
- {
- printf("ERR\n");
- done=;
- }
- p[ch[]-'a']=;
- stk[++stack_num]=ch[]-'a';
- int fl1,num1=,fl2,num2=;
- scanf("%s",ch);
- if(ch[]>=''&&ch[]<='')
- {
- fl1=;
- for(register int j=;j<strlen(ch);++j)num1=(num1<<)+(num1<<)+(ch[j]^'');
- }
- else fl1=;
- scanf("%s",ch);
- if(ch[]>=''&&ch[]<='')
- {
- fl2=;
- for(register int j=;j<strlen(ch);++j)num2=(num2<<)+(num2<<)+(ch[j]^'');
- }
- else fl2=;
- if(fnum!=nxt)continue;
- if(fl1==&&fl2==)nxt=fnum;
- else if(fl1==&&fl2==)
- {
- if(num1>num2)nxt=fnum;
- else nxt=fnum+,sck[++sck_num]=;
- }
- else if(fl1==&&fl2==)
- {
- mark=;
- nnum++;
- if(ans<nnum)ans++;
- nxt=fnum+;
- sck[++sck_num]=;
- }
- else sck[++sck_num]=,nxt=fnum+;
- }
- else
- {
- if(done)continue;
- if(!fnum)
- {
- printf("ERR\n");
- done=;
- }
- if(done)continue;
- if(nxt==fnum+)
- {
- fnum--,nxt--;
- if(sck[sck_num--]==)nnum--;
- }
- else fnum--;
- p[stk[stack_num--]]=;
- }
- }
- if(done)return ;
- if(fnum)
- {
- printf("ERR\n");
- return ;
- }
- if(mark)
- {
- res[]='O',res[]='(',res[]='n',res[]='^';
- int respos=,tmppos=;
- char tmp[];
- while(ans)tmp[++tmppos]=ans%+'',ans/=;
- while(tmppos)res[++respos]=tmp[tmppos--];
- res[++respos]=')';res[++respos]='\0';
- }
- else res[]='O',res[]='(',res[]='',res[]=')',res[]='\0';
- if(!strcmp(s,res))printf("Yes\n");
- else printf("No\n");
- }
- int main()
- {
- freopen("complexity.in","r",stdin);
- freopen("complexity.out","w",stdout);
- scanf("%d",&T);
- while(T--)
- {
- scanf("%d",&n);scanf("%s",s);
- Dealwith();
- }
- return ;
- }
NOIP2017 时间复杂度
【比赛】NOIP2017 时间复杂度的更多相关文章
- [Luogu 3952] NOIP2017 时间复杂度
[Luogu 3952] NOIP2017 时间复杂度 一年的时间说长不长,说短,也不短. 一年之内无数次觉得难得可怕的题目,原来也就模拟这么回事儿. #include <cstdio> ...
- P3952 NOIP2017 时间复杂度
写了两三个小时,麻烦倒是不麻烦,要考虑清楚,想全了 只过了样例提交是不是傻,要自己造数据 数据不大可以用STL 建议自己刚一下,不看代码 #include <iostream> #incl ...
- luoguP3952 [NOIP2017]时间复杂度 模拟
原本只是想看下多久能码完时间复杂度 然后在30min内就码完了,然后一A了???? 首先,这题完全可以离线做 我们先把所有的操作读完,判断合不合法之后,再去判断和标准答案的关系 具体而言 把所有的操作 ...
- [NOIP2017]时间复杂度
题目描述 小明正在学习一种新的编程语言 A++,刚学会循环语句的他激动地写了好多程序并 给出了他自己算出的时间复杂度,可他的编程老师实在不想一个一个检查小明的程序, 于是你的机会来啦!下面请你编写程序 ...
- 【洛谷P3952】[NOIP2017]时间复杂度
时间复杂度 题目链接 对于 100%的数据:L≤100 . 很明显的模拟题 然而考试时还是爆炸了.. 调了一下午.. 蒟蒻表示不会离线操作.. 直接贴代码: #include<cstdio> ...
- NOIP2017 时间复杂度 大模拟
再写一道大模拟题. 由于是限时写的,相当于考场代码,乱的一批. 题目链接:P3952 时间复杂度 先记几个教训: 字符串形式的数字比较大小老老实实写函数,字典序都搞错几次了 栈空的时候不但pop()会 ...
- 【题解】NOIP2017时间复杂度
对大模拟抱有深深的恐惧……不过这次写好像还好?拿个栈维护一下循环的嵌套,然后重定义一下读入即可.记得去年在考场上面死活调不粗来,代码也奇丑无比……希望今年能好一点吧! #include <bit ...
- [NOIP2017]时间复杂度(模拟)
sscanf读入数字,getline(cin,string)读一整行,其余暴力模拟即可. #include<cstdio> #include<string> #include& ...
- Luogu3952 NOIP2017时间复杂度
搞一个栈模拟即可.对比一下和一年前考场上的代码233 //2018.11.8 #include<iostream> #include<cstdio> #include<c ...
随机推荐
- php快速上手总结
PHP作为现代热门主流的开发语言,对于那些想加入新手PHPer,从哪学起,如何学习?你必须要需要掌握PHP的基础知识,基础知识相当于重点,是不可忽视的知识.常用的功能模块,面向对象的,MVC等相关技能 ...
- Netty源码分析第5章(ByteBuf)---->第4节: PooledByteBufAllocator简述
Netty源码分析第五章: ByteBuf 第四节: PooledByteBufAllocator简述 上一小节简单介绍了ByteBufAllocator以及其子类UnPooledByteBufAll ...
- 基于神念TGAM的脑波小车(4)
我使用的是HC05和BT06俩个蓝牙模块 1.[AT模式]HC05蓝牙模块的PIO11接VCC,上电后即进入HC05AT指令模式,对于BT06蓝牙直接上电进入AT模式,用USBT06转TTL模块连接到 ...
- 1分钟入门接口自动化框架Karate
介绍 在这篇文章中,我们将介绍一下开源的Web-API自动化测试框架——Karate Karate是基于另一个BDD测试框架Cucumber来建立的,并且共用了一些相同的思想.其中之一就是使用Gher ...
- Plasma Cash 合约解读
作者介绍 虫洞社区·签约作者 steven bai Plasma Cash 合约解读 Plasma Cash 合约解读 1. 合约代码 2. 合约文件简单介绍 3. Plasma Cash 的基础数据 ...
- Python-opencv摄像头图像捕获
实例一 (灰色调度) #!/usr/bin/env python # _*_ coding:utf-8 _*_ import cv2 as cv import numpy as np capture ...
- 使用FFMPEG 压缩png图片 与tinypng压缩结果对比
Tinypng https://tinypng.com/ 一个在线png压缩工具 FFmpeg https://ffmpeg.org/download.html 原图 903 kb Tinypng压 ...
- TeamWork#3,Week5,Introduction to the "take-away" Sale Selection Project
一.NABCD 1.N(Need 需求) 当今社会生活节奏快,很多大学生.上班族叫外卖比较普遍,外卖生意异常火爆.最近美团.饿了么等外卖服务竞争激烈,产生了大量外卖优惠信息.而网络上外卖信息比较混乱, ...
- Scurm Meeting 11.2
成员 今日任务 明日计划 用时 徐越 写功能规格说明书,代码移植 创建数据库,代码移植 3h 赵庶宏 编写功能规格说明书,学习访问数据库代码,代码迁移 代码迁移 5h 武鑫 设计界面:独立完成一些简单 ...
- 20162314 《Program Design & Data Structures》Learning Summary Of The Fifth Week
20162314 2017-2018-1 <Program Design & Data Structures>Learning Summary Of The Fifth Week ...