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 个房间含有的旧灯泡个数. ...
随机推荐
- Samba共享目录的多用户权限设置案例
下面根据实际工作中遇到的一个共享目录的多用户权限需求案例来说明下Samba用户权限的设置. 一.需求场景领导:李一(liyi)正式员工(zhengshiyuangong):刘二二(liuerer).于 ...
- gitblit 配置图文详解
Windows平台下Git服务器搭建 前提是确保存在JDK环境. 第一步:下载Gitblit.下载地址:http://www.gitblit.com/ 第二步:解压缩下载的压缩包即可,无需安装. 第三 ...
- 《Linux内核分析》第七周笔记 可执行程序的装载
20135132陈雨鑫 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...
- Linux内核分析作业第六周
创建新进程的过程 一.进程的描述 为了管理进程,内核必须对每个进程进行清晰的描述,进程描述符提供了内核所需了解的进程信息. 1.进程控制块PCB——task_struct 操作系统的三大管理功能 进程 ...
- 关于HashMap和Hashtable的区别
Hashtable的应用非常广泛,HashMap是新框架中用来代替Hashtable的类,也就是说建议使用HashMap,不要使用Hashtable.可能你觉得Hashtable很好用,为什么不用呢? ...
- 使用Spring提供的缓存抽象机制整合EHCache为项目提供二级缓存
Spring自身并没有实现缓存解决方案,但是对缓存管理功能提供了声明式的支持,能够与多种流行的缓存实现进行集成. Spring Cache是作用在方法上的(不能理解为只注解在方法上),其核心思想是 ...
- slot 插槽的作用域用法(摘自vue.js 官网)
有的时候你希望提供的组件带有一个可从子组件获取数据的可复用的插槽.例如一个简单的 <todo-list> 组件的模板可能包含了如下代码: <ul> <li v-for=& ...
- HTML DOM 学习笔记
一.HTML DOM定义了所有HTML元素的对象和属性,以及访问他们的方法即:HTML DOM是关于如何获取,修改,添加,删除HTML元素的标准二.DOM节点1.分类整个文档是一个文档节点每个HTML ...
- jetty 之 form too large | form too many keys 异常
http://www.jsunw.com/?post=34&tdsourcetag=s_pctim_aiomsg https://wiki.eclipse.org/Jetty/Howto/Co ...
- [转帖] testin 安全测试要点