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 个房间含有的旧灯泡个数. ...
随机推荐
- JavaScript术语:shim 和 polyfill
转自:https://www.html.cn/archives/8339 在学习和使用 JavaScript 的时候,我们会经常碰到两个术语:shim 和 polyfill.它们有许多定义和解释,意思 ...
- 《linux内核设计与实现》第五章
第五章 系统调用 一.与内核通信 系统调用在用户空间进程和硬件设备之间添加了一个中间层.作用: 为用户空间提供了一种硬件的抽象接口. 系统调用保证了系统的稳定和安全. 每个进程都运行在虚拟系统中,而在 ...
- C# 中颜色和名称样式对照表
WPF中的画刷也一样适用 System.Windows.Media.Brushes.名称 (如:System.Windows.Media.Brushes.AliceBlue) :first-child ...
- 8-Python3从入门到实战—基础之数据类型(集合-Sets)
Python从入门到实战系列--目录 集合的定义 集合(set)和字典类似,也是一组key的集合,但不存储value:由于key不能重复,所以,在set中,没有重复的key. 创建一个set,需要提供 ...
- java mail session使用Properties的clone方法
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreem ...
- js获取属性
js获取属性的方法: document.getElementById(); document.getElementsByTagname(); document.getElementsByClassna ...
- 关于Laravel中使用response()方法调用json()返回数据unicode编码转换的问题解决
在网上找了好久没有找到,之后一步一步测试,发现了Laravel还是很强大的,解决方案如下: public function response(){ // 返回json数据 $data = [ 'err ...
- jquery ajax中data属性详解
$.post.$.get是一些简单的方法,如果要处理复杂的逻辑,还是需要用到jQuery.ajax() 一.$.ajax的一般格式 $.ajax({ type: 'POST', url: url , ...
- FICO模块
- Delphi的关键字
Constructor;构造器,定义构造函数使用Constructor关键字