B. Little Artem and Grasshopper

题目连接:

http://www.codeforces.com/contest/669/problem/B

Description

Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.

The area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Grasshopper stops immediately if it jumps out of the strip. Now Artem wants to find out if this will ever happen.

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — length of the strip.

Next line contains a string of length n which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains n integers di (1 ≤ di ≤ 109) — the length of the jump from the i-th cell.

Output

Print "INFINITE" (without quotes) if grasshopper will continue his jumps forever. Otherwise print "FINITE" (without quotes).

Sample Input

2

<
1 2

Sample Output

FINITE

Hint

题意

有一个人有一个院子,是1*n这么大的

每个格子里面都写着一个箭头,表示这个人要往哪儿去跳,并且给你这个人跳跃的距离是多少

然后问你这个人会不会一直跳下去……

题解:

其实这个人只要跳到他之前跳到过的位置,他就会一直循环的跳下去了

代码

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+6;
string s;
int vis[maxn],n,now,jump[maxn];
int main()
{scanf("%d",&n);cin>>s;for(int i=0;i<n;i++)scanf("%d",&jump[i]);while(1){if(vis[now])return puts("INFINITE");vis[now]=1;if(s[now]=='>')now = now + jump[now];else now = now - jump[now];if(now>=n||now<0)return puts("FINITE");}
}

Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B. Little Artem and Grasshopper 模拟题...相关推荐

  1. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D. Little Artem and Dance 模拟

    D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little A ...

  2. Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题

    A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes ...

  3. VK Cup 2016 - Round 1 (Div. 2 Edition) A. Bear and Reverse Radewoosh 水题

    A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Lima ...

  4. VK Cup 2016 - Round 1 (Div. 2 Edition) D. Bear and Polynomials

    D. Bear and Polynomials 题目连接: http://www.codeforces.com/contest/658/problem/D Description Limak is a ...

  5. 【VK Cup 2016 - Round 1 (Div 2 Edition)C】【构造】Bear and Forgotten Tree 3 构造一棵树直径为d且点1的深度为h

    Bear and Forgotten Tree 3 time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  6. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3)

    点击打开A题链接 #include<bits/stdc++.h> using namespace std; const int MAX = 105; int n,s;int h[MAX], ...

  7. Codeforces Round #470 (rated, Div. 2, based on VK Cup 2018 Round 1)B. Primal Sport

    Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try ...

  8. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)C. Voltage Keepsake

    题目链接:C. Voltage Keepsake 题解:二分时间,然后判断看需要充电的时间总和是否在允许的范围内 #include<bits/stdc++.h> #define pb pu ...

  9. VK Cup 2017 - Round 1

    传送门 A. Bear and Friendship Condition(思维or完全图判定) •题意 给你n个人,m个朋友关系 朋友是会传递的,若A B是朋友,A C是朋友,则必须有B C的朋友关系 ...

最新文章

  1. babel6 babel7_当您已经准备好Babel时设置Flow
  2. python下载方法-python下载文件的几种常用方法
  3. Keras.layers各种层介绍,网络层、卷积层、池化层 等
  4. linux日志本地存储和网络存储,文件系统和本地存储管理 1
  5. 个人作业——软件产品分析
  6. WordPress在前台文章页添加后台编辑该文章按钮
  7. Spring MVC源码——Root WebApplicationContext
  8. 再见,余!额!宝!!!
  9. 路由器链路聚合技术(Eth-Trunk、Ip-Trunk)
  10. 十一假期国人消费力爆棚,国内旅游收入超6497亿,你花了多少?
  11. nutch2.3.1 scoring-opic 插件url评分为0 问题
  12. 关于Chrome内核88版本无法正常使用Adobe Flash Player公告
  13. 如何成为数据科学家_成为数据科学家需要了解的10件事
  14. 老是原罪?技术圈为何不待见大龄企业家
  15. KMP--找子串2.0
  16. python中的append()有什么功能_关于列表:在Python中,“。append()”和“+ = []”之间有什么区别?...
  17. Mac Python第三方库安装
  18. 七公江湖烤翅防骗子—常见网络骗子骗术防御要点
  19. 【上电即上华为云】华为云smart智联PLC无线网关_plc_3121N-H(3121N-IED)
  20. AD软件PCB快捷键

热门文章

  1. 人脸检测--SSH: Single Stage Headless Face Detector
  2. 【numpy】tensordot的用法研究
  3. Debian/Ubuntu 对gpg和apt-key使用代理--报错解决:gpg: keyserver receive failed: Connection timed out
  4. 报错解决:cannot import name 'conditional' from 'hyperas.distributions'
  5. 我的世界正版moba服务器,《我的世界》需要氪金?反观《迷你世界》才知道差距!...
  6. C++_模板特化(specialization),模板偏特化(局部特化)(partial specialization)
  7. 任务管理 linux指令qsub,Linux_前一个投的任务跑完再跑另一个任务_qsub_-hold_jid
  8. 怎么把MySQL的数据传入JTable,如何直接从数据库中将数据填充到Jtable
  9. Jenkins用户权限管理
  10. seq2seq模型_直观理解并使用Tensorflow实现Seq2Seq模型的注意机制