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. 36 - 网络编程-TCP编程

    目录 1 概述 2 TCP/IP协议基础 3 TCP编程 3.1 通信流程 3.2 构建服务端 3.3 构建客户端 3.4 常用方法 3.4.1 makefile方法 3.5 socket交互 3.4 ...

  2. Sublime Text2使用规则

    Sublime Text是我发现的有一好用的编辑器,它不单单只支持 python ,几乎支持目前主流的语言,快捷键丰富,可以极大的提高代码开发效率.Sublime Text 网址:http://www ...

  3. css3动画详解

    一.Keyframes介绍: Keyframes被称为关键帧,其类似于Flash中的关键帧.在CSS3中其主要以“@keyframes”开头,后面紧跟着是动画名称加上一对花括号“{…}”,括号中就是一 ...

  4. 统计学习方法三:K近邻

    一.什么是K近邻? K近邻是一种基本的分类和回归方法. 在分类时,对新的实例,根据其K个最近邻的训练实例的类别,通过多数表决权等方式预测其类别. 通俗的讲,找K个和其关系最近的邻居,哪个类别的邻居多, ...

  5. 发布PHP项目(nginx+PHP7+mysql 5.6)

    一.环境检查 1.检查nginx ps -ef | grep "nginx" 显示如下内容则代表nginx启动正常 root 3285 1 0 12:57 ? 00:00:00 n ...

  6. linux中getmntent setmntent endmntent 用法例子

    mntent 结构是在 <mntent.h> 中定义,如下:               struct mntent {                      char    *mnt ...

  7. python抓取链家房源信息

    闲着没事就抓取了下链家网的房源信息,抓取的是北京二手房的信息情况,然后通过网址进行分析,有100页,并且每页的url都是类似的 url = 'https://bj.lianjia.com/ershou ...

  8. wordpress技术-禁止订阅用户访问后台

    begin主题虽然有个功能,但是只是少了入口,实际上测试还是可以进入后台的,那么怎么彻底解决呢?一时半会没思路,百度了下,果然有人贴出了代码. 把下面代码黏贴到主题的模板函数文件里即可: if ( i ...

  9. WordPress插件:WP No Category Base 去除分类Category目录

    不少折腾WordPress的朋友都希望去掉分类链接中的 /category/ 目录标志,网上很多这方面的教程,据倡萌所知,除了使用 WP No Category Base 插件(或类似插件),其他的方 ...

  10. 495. Teemo Attacking

    In LOL world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned ...