Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) B. Little Artem and Grasshopper 模拟题
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 模拟题的更多相关文章
- 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. ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- Tensorflow中使用TFRecords高效读取数据--结合Attention-over-Attention Neural Network for Reading Comprehension
原文链接:https://arxiv.org/pdf/1607.04423.pdf 本片论文主要讲了Attention Model在完形填空类的阅读理解上的应用. 转载:https://blog.cs ...
- iphone6设置企业qq
1.首先要确定foxmail的账户服务器信息,右上角-账户账户管理-服务器设置 2.iphone端:
- webgote的例子(6)SQL注入(盲注)
SQL Injection - Blind (WS/SOAP) 本期演示的是盲注的手法.有些网站在与数据库交互的地方进行了很好的修饰,将报错的语句进行修改,即使你找到了注入点也无法下手拿数据,这个时候 ...
- Linux实用命令之xdg-open
为什么要介绍 xdg-open 呢,得先从需求说起. 一般在控制台中,可以使用命令操作各式文本文件.但难以避免,需要操作一些非文本文件,如 pdf,doc 等. 此时,一般的做法是,打开文件管理器,再 ...
- C# 获取mp3文件的歌曲时间长度
添加命名空间: using Shell32; using System.Text.RegularExpressions;添加引用:COM组件的Microsoft Shell Control ...
- UVA题解二
UVA题解二 UVA 110 题目描述:输出一个Pascal程序,该程序能读入不多于\(8\)个数,并输出从小到大排好序后的数.注意:该程序只能用读入语句,输出语句,if语句. solution 模仿 ...
- nginx allow 多个ip & ipv4的网段表示方法解析
参考:https://www.baidu.com/link?url=5aVe_syihQzhHnSDAdLsNNQYqDe_W2GYG1GeIQ130e4mEZbusxQfqGVTdg-dJg8fqM ...
- MySQL之查漏补缺
1.TRUNCATE语句和DELETE语句的区别 1.delete语句,是DML语句,truncate语句通常被认为是DDL语句. 2.delete语句,后面可以跟where子句,通常指定where子 ...
- 用socket发送匿名邮件之python实现
发送邮件可以用smtp协议,整个过程为: 用户代理(user-agent,比如outlook.foxmail等邮件客户端)---(smtp协议)--->本地邮件服务器 --- (smtp协议)- ...
- 【PAT】1005. 继续(3n+1)猜想 (25)
1005. 继续(3n+1)猜想 (25) 卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中 ...