2018.9青岛网络预选赛(C)
https://www.cnblogs.com/violet-acmer/p/9664805.html
题意:
定义五个指令,判断能否从输入的n条指令中成功跳出循环,如果不能,输出"No",反之,输出"Yes"。
题解:
判断某个数[0,255]是否重复来到某一指令,如果有,则肯定是个无限循环,输出"No",反之,可以跳出循环,输出"Yes"。
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=1e4+; struct Order
{
int v;
int k;
char que[];
};
Order order[maxn];
int n;
int r;
bool vis[maxn][];//vis[index][r] == true : 数r来到index两次,无限循环 void Initial()
{
scanf("%d",&n);
for(int i=;i <= n;++i)
{
scanf("%s%d",order[i].que,&order[i].v);
if(order[i].que[] != 'a')
scanf("%d",&order[i].k);
}
r=;
memset(vis,false,sizeof(vis));
}
bool is_vis(int index,int r)
{
if(vis[index][r] == false)
{
vis[index][r]=true;
return false;
}
return true;
}
bool Process()
{
int index=;
while(index <= n)
{
if(order[index].que[] == 'd')
{
if(is_vis(index,r))
return false; r += order[index++].v;
r %= ;
continue;
}
if(is_vis(index,r) == true)//判断某数r是否重复来到某index指令
return false; if(order[index].que[] == 'e')
index=(r == order[index].v ? order[index].k:index+);
else if(order[index].que[] == 'n')
index=(r != order[index].v ? order[index].k:index+);
else if(order[index].que[] == 'l')
index=(r < order[index].v ? order[index].k:index+);
else if(order[index].que[] == 'g')
index=(r > order[index].v ? order[index].k:index+);
}
return true;
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
Initial();
if(Process())
printf("Yes\n");
else
printf("No\n");
}
return ;
}
2018.9青岛网络预选赛(C)的更多相关文章
- 2018.9青岛网络预选赛(K)
传送门:Problem K https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 给你n个数,找出满足条件的最多的数的个数. 题解: 满足条件 ...
- 2018.9青岛网络预选赛(B)
传送门:Problem(B) https://www.cnblogs.com/violet-acmer/p/9664805.html 参考资料: https://blog.csdn.net/qq_40 ...
- 2018.9青岛网络预选赛(A)
传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 求m个PERFECTs中最多有多少个连续的PERFECT和最 ...
- 2018.9青岛网络预选赛(J)
传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9664805.html 题目大意: BaoBao和DreamGrid玩游戏,轮流按灯的按钮, ...
- 2018.9青岛网络预选赛(H)
传送门:Problem H https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: BaoBao在一条有刻度的路上行走(哈哈,搞笑),范围为 [ ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online(2018 青岛网络预选赛)
A题 A Live Love 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041155943483625472 ...
- 2018 icpc 青岛网络赛 J.Press the Button
Press the Button Time Limit: 1 Second Memory Limit: 131072 KB BaoBao and DreamGrid are playing ...
- 2018 ICPC青岛网络赛 B. Red Black Tree(倍增lca好题)
BaoBao has just found a rooted tree with n vertices and (n-1) weighted edges in his backyard. Among ...
- 2018.9南京网络预选赛(J)
传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9720603.html 变量解释: need[ i ] : 第 i 个房间含有的旧灯泡个数. ...
随机推荐
- Mongodb主从复制/ 副本集/分片集群介绍
前面的文章介绍了Mongodb的安装使用,在 MongoDB 中,有两种数据冗余方式,一种 是 Master-Slave 模式(主从复制),一种是 Replica Sets 模式(副本集). Mong ...
- 浅谈JS的作用域链(一)
JS的执行环境 执行环境(Execution context,EC)或执行上下文,是JS中一个极为重要的概念. 在JavaScript中有三种代码运行环境: Global Code JavaScrip ...
- 牛客国庆集训派对Day6 B.Board
链接 [https://www.nowcoder.com/acm/contest/206/B] 分析 只要在n*n范围内随便找一个斜对角的一个格子去计算就知道了 具体看代码体会吧 代码 #includ ...
- 点评qq浏览器
1.内核. qq浏览器用的是是IE8的内核,而且是只有IE内核,所以,在速度上没办法跟那些webkit内核做对比了,不过也没有太慢,在沈航的网速下,打开网页的速度也还是勉强可以接受的. ...
- Daily Scrum NO.10
工作概况 今天是两周正是开发的最后一个工作日,虽然也是编译的DEADLINE,但成员们还是较为积极.计划内的工作基本都能够完成:线程池.异常清理器和动态爬取的功能.异常清理器界面的第一版也在今晚做了出 ...
- 20135337——linux第四次实践:字符集总结与分析
ASCII & GB2312 & UTF-8 ASCII 主要用于显示现代英语和其他西欧语言.它是现今最通用的单字节编码系统,并等同于国际标准ISO 646: 7位(bits)表示一个 ...
- 小学四则运算APP 第一个冲刺阶段 第六天
团队成员:陈淑筠.杨家安.陈曦 团队选题:小学四则运算APP 第一次冲刺阶段时间:11.17~11.27 本次发布的是重新排列整齐ResultActivity的布局代码activity_result. ...
- Markdown页内跳转实现方法
目录 Markdown页内跳转实现方法 HTML锚点跳转 生成目录 Markdown页内跳转实现方法 [时间:2017-02] [状态:Open] [关键词:markdown,标记语言,页内跳转,ht ...
- ViewDragHelper
参考:Android 之 ViewDragHelper 详解 Android 之 ViewDragHelper详解(二) 看了几篇博客,并参考了上面的两篇博客,整理一下ViewDragHelper ...
- Jquery 组 表单验证
<!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...