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 个房间含有的旧灯泡个数. ...
随机推荐
- centos6.5虚拟机安装后,没有iptables配置文件
openstack环境里安装centos6.5系统的虚拟机,安装好后,发现没有/etc/syscofig/iptables防火墙配置文件. 解决办法如下: [root@kvm-server005 ~] ...
- 个人阅读作业2:结合《No Silver Bullet》谈谈我在软件开发过程的遇到的困难与体会
英文捉急,只能挑一段看得比较懂的,而且正好和我们现在编程任务联系比较紧密的内容来谈一谈体会. 在<No Silver Bullet>中,作者描述了造成软件本质性困难(essence)的四个 ...
- Week 3 有求必应
[引] 必应词典已经伴我很久了,但那并不意味着我天天都用它查来查去,它总是静静地蹲在我E盘的一角. 从前的它特别任性,总喜欢开机自己冒出头来看我.后来我嫌它每天都播报新闻,于是就把它关进了冷宫.直到不 ...
- Linux 第七章学习笔记
1:链接概述 链接(linking)是将各种代码和数据部分收集起来并组合成为一个单一文件的过程,这个文件可被加载(或被拷贝)到存储并执行. 编译系统提供的调用预处理器.编译器.汇编器和链接器来构造目标 ...
- githup地址
githup地址:https://github.com/caowenjing/test.git
- SPRINT四则运算(第二天)
1.小组成员: 李豌湄:master 江丹仪:产品负责人 2.现状: a.已经下载APP分析他们的界面.优缺点和闪光点 b.已改进代码添加功能 3.任务认领: 完成任务的第一个模块: a.下载五个类 ...
- WIN10 Samba(SMB) v1 trouble shooting
现象:WIN10 Education Editon不能访问SMB V1.5的NAS服务器的共享文件夹. 一篇WIN与SMB相关的经验帖:https://jingyan.baidu.com/articl ...
- HTML5 Base64_encoding_and_decoding
https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding In JavaSc ...
- Sqlite,libevent,openssl,mosquito交叉编译
一.设置交叉编译环境 在makefile所在目录(或源代码根目录)打开终端. 在终端中设置交叉编译所需的临时环境变量(也可写到配置文件中设置为全局环境变量),其中交叉编译工具链的名称和目录需要根据实际 ...
- 堆排序获取TopN
package com.zjl.tool.sort; /** * 求前面的最大K个 解决方案:小根堆 (数据量比较大(特别是大到内存不可以容纳)时,偏向于采用堆) * @author 张恩备 * @d ...