题意:给你一个HxW的矩阵,每个点是一个指令,根据指令进行一系列操作。

题解:模拟

#include<cstdio>
#include<algorithm>
using namespace std; const int maxn = ;
char G[maxn][maxn]; int dx[] = {-,,, };
int dy[] = { ,,,-}; struct pointer
{
int r,c;
int dir;
void Move(){
r += dx[dir];
c += dy[dir];
}
char read(){
return G[r][c];
}
}p; int h,w;
const int up_bound = 1e5;
const int TimeLim = 1e6;
const int MaxN = 1e5+;
int readLim;
int readList[MaxN]; void execute()
{
p.r = p.c = ;
int Register[] = {};
int cur = ;
char op = p.read();
p.dir = ;
int step = ;
int ReadTimes = ;
while(op!='#'){
if('A'<=op&&op<='Z'){
swap(Register[op-'A'],cur);
}else switch(op){
case '^':{
p.dir = ;
break;
}
case '>':{
p.dir = ;
break;
}
case 'v':{
p.dir = ;
break;
}
case '<':{
p.dir = ;
break;
}
case '?':{
if(ReadTimes>=readLim){
cur = readList[readLim-];
}else {
cur = readList[ReadTimes];
ReadTimes++;
}
break;
}
case '!':{
printf("%d\n",cur);
cur = ;
break;
}
case '+':{
cur++;
if(abs(cur)>up_bound){
printf("OVERFLOW ERROR\n");
return;
}
break;
}
case '-':{
cur--;
if(abs(cur)>up_bound){
printf("OVERFLOW ERROR\n");
return;
}
break;
}
case '@':{
if(cur){ p.dir = (p.dir+)%; }
else { p.dir = (p.dir+)%; }
break;
}
}
step++;
if(step>TimeLim) {
printf("TIME LIMIT EXCEEDED\n");
return;
}
p.Move();
if(p.r<||p.r>=h||p.c<||p.c>=w) {
printf("RUNTIME ERROR\n"); return;
}
op = p.read();
}
} int main()
{
scanf("%d%d",&h,&w);
for(int i = ; i < h; i++)
scanf("%s",G[i]);
scanf("%d",&readLim);
for(int i = ; i < readLim; i++){
scanf("%d",readList+i);
}
execute(); return ;
}

URAL 2027 URCAPL, Episode 1 (模拟)的更多相关文章

  1. URAL 1069 Prufer Code(模拟)

    Prufer Code Time limit: 0.25 secondMemory limit: 8 MB A tree (i.e. a connected graph without cycles) ...

  2. URAL(timus) 1280 Topological Sorting(模拟)

    Topological Sorting Time limit: 1.0 secondMemory limit: 64 MB Michael wants to win the world champio ...

  3. URAL 2027 2028 两个有趣的题

    这两个题,讲的是有一种奇怪的语言,代码是一种二维的矩阵. 前一个题,是根据所给的要求,写一个简单的解释器. 后一个题,是用那种语言写一个简单的小程序. 挺有意思的,所以在这里纪念一下.顺便那个语言的原 ...

  4. ural 1218. Episode N-th: The Jedi Tournament

    1218. Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Je ...

  5. 模拟 URAL 1149 Sinus Dances

    题目传送门 /* 模拟:找到规律分别输出就可以了,简单但是蛮有意思的 */ #include <cstdio> #include <algorithm> #include &l ...

  6. URAL 1218 Episode N-th: The Jedi Tournament(强连通分量)(缩点)

    Episode N-th: The Jedi Tournament Time limit: 1.0 secondMemory limit: 64 MB Decided several Jedi Kni ...

  7. URAL 2046 A - The First Day at School 模拟题

    A - The First Day at SchoolTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudg ...

  8. URAL 1404. Easy to Hack! (模拟)

    space=1&num=1404">1404. Easy to Hack! Time limit: 1.0 second Memory limit: 64 MB When Vi ...

  9. URAL 1993 This cheeseburger you don't need 模拟题

    This cheeseburger you don't need 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1993 Descrip ...

随机推荐

  1. js学习笔记3:with语句的使用

    with语句 with是ECMAScript规定的内容,主要用于设置代码在特定对象中的作用域. var sMessage = "hello"; with(sMessage) { c ...

  2. 安装Matlab出现Error 1935错误解决方法

    1.开始 - 运行(输入regedit.exe)- 确定或者回车,打开注册表编辑器: 2.在打开的注册表编辑器中找到:HKEY_LOCAL_MACHINE ,并展开:HKEY_LOCAL_MACHIN ...

  3. C++读取XML,tinyXml的使用

    前言: 最近在开发的过程中,有个需求是对xml进行格式转化,从一种格式转化到另外一种格式.因此,就需要读取xml进行处理.原本打算写成工具在linux下运行,不过后来考虑到和系统结合,最后也就使用了前 ...

  4. HDU - 6201 transaction transaction transaction(树形dp取两点)

    transaction transaction transaction Kelukin is a businessman. Every day, he travels around cities to ...

  5. HDU - 6415 多校9 Rikka with Nash Equilibrium(纳什均衡+记忆化搜索/dp)

    Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 524288/524288 K ...

  6. HN669打包工具--环境准备

    1.安装JDK 这个百度,Google一大堆,可以自行参考.仅仅注意,不要安装错了,根据自己系统是32位还是64位,安装MAC下的JDK版本.系统32/64位查询命令:uname -a下载地址安装指导 ...

  7. CABasicAnimation动画及其keypath值和作用

    //tarnsform放大缩小动画 CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transf ...

  8. SQL Server(三)

    一.数据库操作 create database 数据库名称 ——创建drop database 数据库名称 ——删除use 数据库名称 ——使用go 两条SQL语句之间分隔 二.表的操作 create ...

  9. 51nod1255(栈)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1255 题意:中文题诶- 思路:对于当前字符 s[i],若其不在 ...

  10. 洛谷P3797 妖梦斩木棒

    P3797 妖梦斩木棒 题目背景 妖梦是住在白玉楼的半人半灵,拥有使用剑术程度的能力. 题目描述 有一天,妖梦正在练习剑术.地面上摆放了一支非常长的木棒,妖梦把它们切成了等长的n段.现在这个木棒可以看 ...