-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path669B.cpp
More file actions
61 lines (60 loc) · 1.1 KB
/
669B.cpp
File metadata and controls
61 lines (60 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
#define mod 1000000007
#define FOR(i, a, b) for (i = a; i < b; i++)
using namespace std;
typedef long long ll;
void printV(vector<ll> v)
{
for (int i = 0; i < v.size(); i++)
cout << v[i] << " ";
}
int modexp(ll A, ll B, ll C)
{
if (A == 0)
return 0;
if (B == 0)
return 1;
ll y;
if (B % 2 == 0)
{
y = modexp(A, B / 2, C);
y = (y * y) % C;
}
else
{
y = A % C;
y = (y * modexp(A, B - 1, C) % C) % C;
}
return (ll)((y + C) % C);
}
int main()
{
ll n;
cin >> n;
unordered_set<ll> s;
string jumps;
cin >> jumps;
ll lens[n];
for (ll &e : lens)
cin >> e;
ll curr = 0;
s.insert(curr);
int flag = 0;
while (curr >= 0 && curr < n)
{
if (jumps[curr] == '>')
curr += lens[curr];
else
curr -= lens[curr];
if (s.find(curr) != s.end())
{
flag = 1;
break;
}
s.insert(curr);
}
if (flag)
cout << "INFINITE\n";
else
cout << "FINITE\n";
}