题意:给你一个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. 优酷电视剧爬虫代码实现一:下载解析视频网站页面(4)补充: Java正则表达式Matcher.group(int group)相关类解析

    在Java正则表达式的相关类Matcher中,有如下几个方法: - int groupCount() - String group(int group) - int start(int group)  ...

  2. ColorMask与Blend

    Shader "N/T" { Properties { _Color ("Texture to blend", Color) = (1,1,1,1) } Sub ...

  3. Spark history server 遇到的一些问题

    最近学习Spark,看了一个视频,里面有提到启动spark后,一般都会启动Spark History Server.视频里把 spark.history.fs.logDirectory 设置成了Had ...

  4. poj 3417 Network(tarjan lca)

    poj 3417 Network(tarjan lca) 先给出一棵无根树,然后下面再给出m条边,把这m条边连上,然后每次你能毁掉两条边,规定一条是树边,一条是新边,问有多少种方案能使树断裂. 我们设 ...

  5. 洛谷P2875 [USACO07FEB]牛的词汇The Cow Lexicon

    P2875 [USACO07FEB]牛的词汇The Cow Lexicon 题目描述 Few know that the cows have their own dictionary with W ( ...

  6. Java:创建线程

    Java定义了两种创建线程的方法: 1.实现Runnable接口 要实现Runnable接口,只需简单地实现run()方法即可,声明如下:public void run() 在run()方法中,可以定 ...

  7. Huber鲁棒损失函数

    在统计学习角度,Huber损失函数是一种使用鲁棒性回归的损失函数,它相比均方误差来说,它对异常值不敏感.常常被用于分类问题上. 下面先给出Huber函数的定义: 这个函数对于小的a值误差函数是二次的, ...

  8. javascript中的style只能取到在HTML中定义的css属性

    如果在css中定义的 li{ width:100px; left:100px; top:; position:absolute; font-style:normal; } 这样执行: oli[0].s ...

  9. Mysql和oracle字段类型与java对象类型对应表收藏

    https://blog.csdn.net/michaelzhou224/article/details/16827029 Mysql Oracle Java BIGINT NUMBER(19,0) ...

  10. NET API 分析器

    NET API 分析器 https://www.hanselman.com/blog/WritingSmarterCrossplatformNETCoreAppsWithTheAPIAnalyzerA ...