题意:给你一个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. css hack汇总

    注意点: 网上很多资料中常常把!important也作为一个hack手段,其实这是一个误区.!important常常被我们用来更改样式,而不是兼容hack.造成这个误区的原因是IE6在某些情况下不主动 ...

  2. asp.net清空页面上的所有TextBox

    Asp.net中一次性清空页面上的所有TextBox中的内容,由于TextBox在客户端以<input type=”text”>形式来呈现的,因此解决方案有客户端和服务器端两种方式,服务器 ...

  3. conntrack-tools使用

    基础用法 系统配置 ### 开启流数据包统计(packets和bytes) # echo "net.netfilter.nf_conntrack_acct=1" >> ...

  4. 洛谷P2868 [USACO07DEC]观光奶牛Sightseeing Cows

    P2868 [USACO07DEC]观光奶牛Sightseeing Cows 题目描述 Farmer John has decided to reward his cows for their har ...

  5. 修正linux系统时间

    date 安装ntpdate工具# yum -y install ntp ntpdate 设置系统时间与网络时间同步# ntpdate cn.pool.ntp.org 将系统时间写入硬件时间# hwc ...

  6. 《SQL 进阶教程》 case:练习题1-1-1 多列数据的最大值

    select name, case when case when x > y then x else y end < z then z else case when x < y th ...

  7. HDU-1845-Jimmy's Assignment

    链接:https://vjudge.net/problem/HDU-1845 题意: 给一个有向图,求最大匹配. 思路: 有相图的最大匹配,可以通过加上反向边, 求这个无向图的最大匹配, 原图的最大匹 ...

  8. NET Core 防止跨站请求

    ASP.NET Core 防止跨站请求伪造(XSRF/CSRF)攻击 什么是反伪造攻击? 跨站点请求伪造(也称为XSRF或CSRF,发音为see-surf)是对Web托管应用程序的攻击,因为恶意网站可 ...

  9. windows 2008 r2或win7安装SP1补丁,安装sqlserver 2012

    说明:安装sql server 2012时,win7和win2008r2系统都需要打sp1补丁. 1.SP1补丁下载地址(建议用迅雷下载): http://download.microsoft.com ...

  10. 牛客网Java刷题知识点之什么是匿名内部类、匿名内部类的使用原则、匿名内部类初始化、匿名内部类使用的形参为何要为final 和 案例

    不多说,直接上干货! 什么是匿名内部类 匿名内部类就是没有名字的内部类. 不使用关键字class . extends .implements 没有构造函数 必须继承其他类或实现其他接口 正因为没有名字 ...