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

    题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2. ...

  2. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 1 Edition) C. Little Artem and Random Variable 数学

    C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Descriptio ...

  3. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) E. Little Artem and Time Machine 树状数组

    E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description L ...

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

  5. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) C. Little Artem and Matrix 模拟

    C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little ...

  6. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题

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

  7. Codeforces Round #348(VK Cup 2016 - Round 2)

    A - Little Artem and Presents (div2) 1 2 1 2这样加就可以了 #include <bits/stdc++.h> typedef long long ...

  8. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) D

    D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  9. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) C

    C. Little Artem and Matrix time limit per test 2 seconds memory limit per test 256 megabytes input s ...

随机推荐

  1. JavaScript实现水平进度条拖拽效果

    <html> <head> <meta charset="UTF-8"> <title>Document</title> ...

  2. 64_t6

    texlive-recipebook-svn37026.0-33.fc26.2.noarch.rpm 24-May-2017 15:44 37946 texlive-recipecard-doc-sv ...

  3. 64_n2

    nodejs-from-0.1.3-4.fc26.noarch.rpm 11-Feb-2017 15:01 9982 nodejs-from2-2.1.0-6.fc26.noarch.rpm 11-F ...

  4. sqlalchemy更新和插入操作

    def save_app_info(self): try: # update app_info print(self.dicts) data = db_session.query(App_Info). ...

  5. jplayer.js 与 video.js

    HTML5 - 两款基于JS的视频播放器 都是基于h5 video 标签,如果不支持则会自动转成flash,这里个人比较推荐使用jplayer; 1.video.js pc端有时候会与视频打交道,如果 ...

  6. IP负载均衡技术

    参考链接:http://www.360doc.com/content/12/1117/19/820209_248442094.shtml

  7. Myeclipse编辑jsp文件很卡是什么原因?

    可能是配置问题,配置的时候不要把myeclipse连接到网络.否则每次编辑的时候要在网上查找,所以照成很卡.window->perferences->java->Installed ...

  8. web.xml中的dispatchservlet后,js,css,甚至gif都不能正常显示

    这个可以说是很多初学Springmvc的人都会碰到一个令人头痛的问题 那就是为什么我配置好web.xml中的dispatchservlet后,js,css,甚至gif都不能正常显示了 我们来看看我们配 ...

  9. ISSCC 2017论文导读 Session 14:A 288μW Programmable Deep-Learning Processor with 270KB On-Chip Weight

    A 288μW Programmable Deep-Learning Processor with 270KB On-Chip Weight Storage Using Non-Uniform Mem ...

  10. jmeter-----如何安装插件管理?

    1.下载插件管理jar文件,http://www.jmeter-plugins.org/wiki/PluginsManager/ 2. 拷贝这jar文件到 \lib\ext文件夹里 3. 重新打开JM ...