| Task: | Peli |
| Sender: | rasastusni |
| Submission time: | 2020-11-07 22:28:29 +0200 |
| Language: | Python2 (PyPy2) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | WRONG ANSWER | 0.14 s | 1, 2 | details |
| #2 | RUNTIME ERROR | 0.22 s | 2 | details |
Code
#!/usr/bin/env python
seen_states = []
def solve(n, first, second, prev_move, turn):
#print n, first, second, prev_move, turn
if (first, second, prev_move, turn) in seen_states:
return turn
seen_states.append((first, second, prev_move, turn))
if first > 0 and prev_move != 2:
winner = solve(n, first - 1, second, 1, not turn)
if winner == turn:
return winner
if first + 1 != second and prev_move != 1:
winner = solve(n, first + 1, second, 2, not turn)
if winner == turn:
return winner
if second + 1 < n and prev_move != 3:
winner = solve(n, first, second + 1, 4, not turn)
if winner == turn:
return winner
if second - 1 != first and prev_move != 4:
winner = solve(n, first, second - 1, 3, not turn)
if winner == turn:
return winner
return not turn
#for n in range(2, 16):
# for l in range(n - 1):
# for r in range(l + 1, n):
# seen_states = []
# sol = 2 if solve(n, l, r, None, False) else 1
# if sol != (r - l) % 2 + 1:
# print n, l, r, sol
#
#raise Exception('done')
t = int(raw_input())
for x in range(t):
seen_states = []
thing = raw_input()
first = thing.find('P')
second = first + 1 + thing[first+1:].find('P')
print 2 if solve(len(thing), first, second, None, False) else 1
Test details
Test 1
Group: 1, 2
Verdict: WRONG ANSWER
| input |
|---|
| 100 PP. P......P. .PP ..P.P. ... |
| correct output |
|---|
| 2 2 2 1 2 ... |
| user output |
|---|
| 2 1 2 1 2 ... Truncated |
Test 2
Group: 2
Verdict: RUNTIME ERROR
| input |
|---|
| 100 ................................. |
| correct output |
|---|
| 2 1 2 1 1 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 43, in <module>
print...