| Task: | Peli |
| Sender: | Username* |
| Submission time: | 2026-01-17 16:34:09 +0200 |
| Language: | Python3 (CPython3) |
| Status: | READY |
| Result: | 55 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 17 |
| #2 | ACCEPTED | 38 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.22 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.22 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.23 s | 2, 3 | details |
| #4 | RUNTIME ERROR | 0.23 s | 3 | details |
| #5 | ACCEPTED | 0.23 s | 2, 3 | details |
| #6 | RUNTIME ERROR | 0.24 s | 3 | details |
Code
t = int(input())
s = 101
dp = []
#print(dp)
vis = []
for i in range(s):
vis.append([False]*s)
dp.append([0]*s)
#print(vis)
# if abs(a-b)==1
def get(a, b):
#print(vis)
if(vis[a][b]):
return dp[a][b]
if (a<=0 or b<=0):
dp[a][b] = 0
vis[0][0] = True
return 0
if ((a==1 and b==2) or (a==2 and b==1)):
dp[a][b] = 1
vis[a][b] = True
return 1
value = 1
flag = False
for i in range(a):
if(get(a-i-1,b) == 1):
flag = True
for j in range(b):
if(get(a,b-j-1) == 1):
flag = True
for k in range(min(a,b)):
if(get(a-k-1,b-k-1) == 1):
flag = True
if (a == b or flag):
value = 0
dp[a][b] = value
vis[a][b] = True
return value
# 0 = current 1 = next
def win (size):
for x in range(size):
for y in range(size):
#print(x,y)
dp[x][y]=get(x,y)
vis[x][y]=True
win(s)
#print("Done.")
inputs = []
for i in range(t):
a, b = [int(x) for x in input().split()]
inputs.append((a,b))
for pair in inputs:
a, b = pair
print("second" if dp[a][b] else "first")
Test details
Test 1 (public)
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 5 2 2 1 2 3 2 4 3 ... |
| correct output |
|---|
| first second first first second |
| user output |
|---|
| first second first first second |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 100 1 1 1 2 1 3 1 4 ... |
| correct output |
|---|
| first second first first first ... |
| user output |
|---|
| first second first first first ... |
Test 3
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 82 14 91 84 13 97 92 23 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| first first first first first ... |
Test 4
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 1630 271 1812 1671 254 1938 1827 443 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 67, in <module>
print("second" if dp[a][b] else "first")
~~^^^
IndexError: list index out of rangeTest 5
Group: 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 36 14 79 81 93 82 32 1 ... |
| correct output |
|---|
| first first first first first ... |
| user output |
|---|
| first first first first first ... |
Test 6
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 486 300 899 1455 879 543 40 65 ... |
| correct output |
|---|
| second second second second second ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "/box/input/code.py", line 67, in <module>
print("second" if dp[a][b] else "first")
~~^^^
IndexError: list index out of range