-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ef9549
commit 4b1f308
Showing
7 changed files
with
2,917 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
t = int(input()) | ||
|
||
|
||
def can_leave_maze(maze): | ||
if maze[0][0] == 1: | ||
return False | ||
|
||
to_visit = [(0, 0)] | ||
marked_to_visit = {(0, 0): 1} | ||
|
||
while to_visit: | ||
current = to_visit.pop() | ||
to_visit_from_current = ( | ||
(current[0] - 1, current[1]), | ||
(current[0], current[1] - 1), | ||
(current[0] + 1, current[1]), | ||
(current[0], current[1] + 1), | ||
) | ||
|
||
for x, y in to_visit_from_current: | ||
if ( | ||
x in (-1, 5) | ||
or y in (-1, 5) | ||
or maze[x][y] == 1 | ||
or (x, y) in marked_to_visit | ||
): | ||
continue | ||
|
||
if x == 4 and y == 4: | ||
return True | ||
|
||
to_visit.append((x, y)) | ||
marked_to_visit[(x, y)] = 1 | ||
|
||
return False | ||
|
||
|
||
for _ in range(t): | ||
# It seems the input is not regular on beecrowd. | ||
# Sometimes it has blank lines and sometimes doesn't | ||
maze = [] | ||
while len(maze) != 5: | ||
line = input().strip() | ||
if line: | ||
maze.append(list(map(int, line.split()))) | ||
|
||
if can_leave_maze(maze): | ||
print('COPS') | ||
else: | ||
print('ROBBERS') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
TESTCASES=400 | ||
MATRIX_SIZE=5 | ||
|
||
echo "${TESTCASES}" | ||
|
||
for _ in $(seq "${TESTCASES}"); do | ||
echo | ||
for _ in $(seq "${MATRIX_SIZE}"); do | ||
for i in $(seq "${MATRIX_SIZE}"); do | ||
if [[ ${i} -ne 1 ]]; then | ||
echo -n " " | ||
fi | ||
if [[ $((RANDOM % 3)) -eq 0 ]]; then | ||
echo -n "1" | ||
else | ||
echo -n "0" | ||
fi | ||
done | ||
echo | ||
done | ||
done | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.