传送门:Problem 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)的更多相关文章

  1. 2018.9青岛网络预选赛(K)

    传送门:Problem K https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 给你n个数,找出满足条件的最多的数的个数. 题解: 满足条件 ...

  2. 2018.9青岛网络预选赛(B)

    传送门:Problem(B) https://www.cnblogs.com/violet-acmer/p/9664805.html 参考资料: https://blog.csdn.net/qq_40 ...

  3. 2018.9青岛网络预选赛(A)

    传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: 求m个PERFECTs中最多有多少个连续的PERFECT和最 ...

  4. 2018.9青岛网络预选赛(J)

    传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9664805.html 题目大意: BaoBao和DreamGrid玩游戏,轮流按灯的按钮, ...

  5. 2018.9青岛网络预选赛(H)

    传送门:Problem H https://www.cnblogs.com/violet-acmer/p/9664805.html 题意: BaoBao在一条有刻度的路上行走(哈哈,搞笑),范围为 [ ...

  6. The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online(2018 青岛网络预选赛)

    A题 A Live Love 原题链接:https://pintia.cn/problem-sets/1036903825309761536/problems/1041155943483625472 ...

  7. 2018 icpc 青岛网络赛 J.Press the Button

    Press the Button Time Limit: 1 Second      Memory Limit: 131072 KB BaoBao and DreamGrid are playing ...

  8. 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 ...

  9. 2018.9南京网络预选赛(J)

    传送门:Problem J https://www.cnblogs.com/violet-acmer/p/9720603.html 变量解释: need[ i ] : 第 i 个房间含有的旧灯泡个数. ...

随机推荐

  1. combox的基本应用

    easyui-combox:控件的初始化: 可以在其中进行文字的筛选功能(过滤), 动态加载数据的方法. <!DOCTYPE html><html lang="en&quo ...

  2. 《Linux内核分析》实践3

    <Linux>实践--程序破解 一.掌握NOP.JNE.JE.JMP.CMP汇编指令的机器码 NOP:NOP指令即"空指令".执行到NOP指令时,CPU什么也不做,仅仅 ...

  3. 《Linux内核分析》chapter4

  4. <构建之法>13-17

    13章软件测试. 从基本名词到软件测试的分类方法,啃完这15页书,至少对与软件测试的理解程度不是停留在以前的层次(让用户使用,然后提出碰到什么问题) 测试不是那么简单就阐述的完全.测试按测试目的分类可 ...

  5. Android 學習之旅!(1)

    就這樣就過去了一年加一個學期,現在是大二第二個學期而且是下半學期了,以前都是無所事事,沒事睡睡覺,打打遊戲就過去了,但是想到家境和以後的路,我還是決心自己找點東西學習下,以後出去還能有一技之長(雖然可 ...

  6. PAT 1028 人口普查

    https://pintia.cn/problem-sets/994805260223102976/problems/994805293282607104 某城镇进行人口普查,得到了全体居民的生日.现 ...

  7. 命令行批量修改IP并ping测试

    @echo off set ip=0 :beginset /a ip=%ip%+1netsh interface ip set address "本地连接" static 172. ...

  8. Intel SP处理机以及AMD处理器的一些对比资料

    1. EPYC 与 intel的CPU对比 2. Intel SP处理器参数: 3. AMD处理器参数 4. Intel SP处理器部分参数2 5. Intel SP处理器简单说明 6. intel ...

  9. poj 3177 Redundant Paths(边双连通分量+缩点)

    链接:http://poj.org/problem?id=3177 题意:有n个牧场,Bessie 要从一个牧场到另一个牧场,要求至少要有2条独立的路可以走.现已有m条路,求至少要新建多少条路,使得任 ...

  10. python之使用smtplib模块发送邮件

    # 使用smtplib模块发送邮件 import smtplib from email.mime.text import MIMEText from email.header import Heade ...