NOIP模拟81
T1 语言
解题思路
模拟即可,对于一个合法的句子直接判断每一个前缀和每一个后缀是否是合法的名词词组。
然后枚举动词的位置判断前后两段是否合法就好了。
code
#include<bits/stdc++.h>
#define int long long
#define ull unsigend long long
#define f() cout<<"Failed"<<endl
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();};
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
const int N=1e5+10;
int T,n,s[30];
char ch[N];
bool can1[N],can2[N];
inline bool juda(int x){return x&1;}
inline bool judn(int x){return x&2;}
inline bool judv(int x){return x&4;}
void solve()
{
for(int i=0;i<26;i++) s[i]=read();
scanf("%s",ch+1); n=strlen(ch+1);
for(int i=1;i<=n;i++) can1[i]=can2[i]=false;
for(int i=1;i<=n;i++)
if(!juda(s[ch[i]-'a'])&&!judn(s[ch[i]-'a'])) break;
else if(judn(s[ch[i]-'a'])) can1[i]=true;
if(judn(s[ch[n]-'a']))
for(int i=n;i>=1;i--)
if(!juda(s[ch[i]-'a'])&&!judn(s[ch[i]-'a'])) break;
else can2[i]=true;
for(int i=2;i<n;i++)
if(judv(s[ch[i]-'a'])&&can1[i-1]&&can2[i+1])
return printf("Yes\n"),void();
printf("No\n");
}
#undef int
int main()
{
#define int long long
freopen("language.in","r",stdin); freopen("language.out","w",stdout);
T=read(); while(T--) solve();
return 0;
}
T2 色球
解题思路
复杂度可以达到 \(\mathcal{O}(n)\) 用链表实现标记是否反转即可。。
当然我比较懒,暴力做法+双端队列启发式合并复杂度就是 \(\mathcal{O}{nlogn}\) 的了。
code
#include<bits/stdc++.h>
#define int long long
#define ull unsigend long long
#define f() cout<<"Failed"<<endl
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();};
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
const int N=2e5+10;
int n,m,id[N],rev[N];
deque<pair<int,int> > q[N];//col,sum
char opt[10];
inline void insert_front(int sum,int col,int x)
{
if(!q[x].size()) q[x].push_back(make_pair(col,sum));
else if(q[x].back().first==col){sum+=q[x].back().second;q[x].pop_back();q[x].push_back(make_pair(col,sum));}
else q[x].push_back(make_pair(col,sum));
}
inline void insert_back(int sum,int col,int x)
{
if(!q[x].size()) q[x].push_front(make_pair(col,sum));
else if(q[x].back().first==col){sum+=q[x].front().second;q[x].pop_front();q[x].push_front(make_pair(col,sum));}
else q[x].push_front(make_pair(col,sum));
}
inline void insert(int sum,int col,int x)
{
if(!rev[x]) insert_front(sum,col,x);
else insert_back(sum,col,x);
}
inline void move_front(int x,int y)
{
for(int sum=0;sum<y;)
{
pair<int,int> temp=q[x].back(); q[x].pop_back();
if(temp.second<y-sum){sum+=temp.second;continue;}
temp.second-=y-sum; q[x].push_back(temp);
return printf("%lld\n",temp.first),void();
}
}
inline void move_back(int x,int y)
{
for(int sum=0;sum<y;)
{
pair<int,int> temp=q[x].front(); q[x].pop_front();
if(temp.second<y-sum){sum+=temp.second;continue;}
temp.second-=y-sum; q[x].push_front(temp);
return printf("%lld\n",temp.first),void();
}
}
inline void move(int x,int y)
{
if(!rev[x]) move_front(x,y);
else move_back(x,y);
}
inline void merge_work(int x,int y)
{
if(!rev[x]) while(!q[x].empty()) insert(q[x].back().second,q[x].back().first,y),q[x].pop_back();
else while(!q[x].empty()) insert(q[x].front().second,q[x].front().first,y),q[x].pop_front();
}
inline void merge(int &x,int &y)
{
if(q[x].size()<q[y].size()) merge_work(x,y);
else merge_work(y,x),swap(x,y),rev[y]^=1;
}
#undef int
int main()
{
#define int long long
freopen("color.in","r",stdin); freopen("color.out","w",stdout);
n=read(); m=read();
for(int i=1;i<=n;i++) id[i]=i;
while(m--)
{
int x,y,z; scanf("%s",opt+1); x=read(); y=read();
if(strlen(opt+1)==4) z=read(),insert(x,y,id[z]);
else if(opt[2]=='o') move(id[y],x);
else merge(id[x],id[y]);
}
return 0;
}
T3 斐波
大坑未补
T4 偶数
KMP 求最长 boder
可以得到 40pts (code)
大坑未补
NOIP模拟81的更多相关文章
- Noip模拟81 2021.10.20
T1 语言 比较简单的题,然后就瞎写了,所以考场上就我一个写了线段树的,所以我的常数.... 所以就枚举动词的位置,找前面后面有没有出现$4$即可 1 #include<bits/stdc++. ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 2019.8.3 [HZOI]NOIP模拟测试12 C. 分组
2019.8.3 [HZOI]NOIP模拟测试12 C. 分组 全场比赛题解:https://pan.baidu.com/s/1eSAMuXk 刚看这题觉得很难,于是数据点分治 k只有1和2两种,分别 ...
- NOIP 模拟4 T2
本题属于二和一问题 子问题相互对称 考虑对于问题一:知a求b 那么根据b数组定义式 显然能发现问题在于如何求dis(最短路) 有很多算法可供选择 dijsktra,floyed,bfs/dfs,spf ...
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
随机推荐
- js深浅复制(拷贝)
从两种数据类型说起 在js中,变量的类型可以大致分成两种:基本数据类型和引用数据类型,其中基本数据类型指的是简单的数据段,包括: Undefined Null Boolean Number Strin ...
- 《c#高级编程》第5章C#5.0中的更改(十一)——字符串插值
在 C# 5 中,引入了字符串插值(string interpolation)语法,它提供了一种简单.直观的方式来将变量的值嵌入到字符串中.在以前的版本中,我们需要使用字符串格式化功能来实现这个目的, ...
- 07cj031,07CJ03-1图集免费下载
简介 07CJ03-1轻钢龙骨石膏板隔墙.吊顶图集是中国建筑标准设计研究院组织编写的一部针对轻钢龙骨.石膏板材料用于非承重隔墙.室内吊顶装修的装修.建造参考资料,为用户提供专业的建造参考 下载 有需要 ...
- 【数学】主成分分析(PCA)的详细深度推导过程
Based on Deep Learning (2017, MIT) book. 本文基于Deep Learning (2017, MIT),推导过程补全了所涉及的知识及书中推导过程中跳跃和省略的部分 ...
- Pygame安装以及解决问题:Try to run this command from the system terminal. Make sure that you use the correct version of 'pip......
在这里记录一下我的安装过程: 1.首先找到自己python程序安装目录下的Scripts文件夹(里面有pip这里面): 2.使用快捷键win + R 打开终端,先进入到安装python的盘符,然后进入 ...
- 阿里巴巴云原生 etcd 服务集群管控优化实践
简介: 这些年,阿里云原生 etcd 服务发生了翻天覆地的变化,这篇文章主要分享一下 etcd 服务在面对业务量大规模增长下遇到的问题以及我们是如何解决的,希望对读者了解 etcd 的使用和管控运维提 ...
- EDAS 4.0 助力企业一站式实现微服务架构转型与 K8s 容器化升级
简介: EDAS 正式来到 4.0 时代,发布多项重磅新能力:同时联合新产品-云原生应用设计开发平台 ADD 1.0,一起发布云原生应用研发&运维 PaaS 产品家族,助力企业应用架构现代化 ...
- coredump 瘦身风云
简介: minicoredump神也! 继上一篇非典型程序员青囊搞定内存泄露问题后,美美地睡了一觉.睡梦中,突然金光闪闪,万道光芒照进时光隧道,恍惚来到大唐神龙年间.青囊此时化身狄仁杰高级助理, ...
- Serverless 工程实践 | Serverless 应用开发观念的转变
简介: Serverless 架构带来的除了一种新的架构.一种新的编程范式,还包括思路上的转变,尤其是开发过程中的一些思路转变.有人说要把 Serverless 架构看成一种天然的分布式架构,需要用 ...
- [GPT] quasar 在 setup() 周期阶段想设置meta信息,如何获取当前的 route 参数动态设置
在Vue 3 的Composition API(组合式API)中,特别是在 setup() 钩子函数阶段, 由于没有访问到常规的 Vue 实例(this上下文),所以不能直接使用 this.$rout ...