forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
34 lines (29 loc) · 688 Bytes
/
B.cpp
File metadata and controls
34 lines (29 loc) · 688 Bytes
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
#include <bits/stdc++.h>
using namespace std;
const int STEP = 80000000;
string a[10][10];
char trees[STEP * 2 + 10];
int main()
{
freopen("beavers.in", "r", stdin);
freopen("beavers.out", "w", stdout);
ios::sync_with_stdio(0);
for (int j = 0; j < 5; j++)
for (int i = 0; i < 2; i++)
cin >> a[i][j];
int x = STEP, mood = 0;
for (int step = 0; step < STEP; step++)
{
string cur = a[trees[x]][mood];
trees[x] = cur[0] - '0';
if (cur[1] == 'L') x--;
else x++;
mood = cur[2] - 'A';
if (mood >= 5)
{
cout << "happy beaver" << endl;
return 0;
}
}
cout << "unhappy beaver" << endl;
}