Submission details
Task:Peli
Sender:Username*
Submission time:2026-01-17 16:34:09 +0200
Language:Python3 (CPython3)
Status:READY
Result:55
Feedback
groupverdictscore
#1ACCEPTED17
#2ACCEPTED38
#30
Test results
testverdicttimegroup
#1ACCEPTED0.22 s1, 2, 3details
#2ACCEPTED0.22 s1, 2, 3details
#3ACCEPTED0.23 s2, 3details
#40.23 s3details
#5ACCEPTED0.23 s2, 3details
#60.24 s3details

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:

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 range

Test 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:

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