I got nzec error in the below code :it is the sol. for conflip easy exercise

try:
t=int(input())
g=int(input())
for i in range(t):
for i in range(g):
i,n,f=map(int,input().split())
if n%2!=0:
if i==f :
a=n//2
else:
a=(n//2)+1
else:
if n%2==0:
a=n//2
print(a)
except:
pass

Please Format your code and also provide a link to the question in the description. :slightly_smiling_face:

Edit:
I believe you’re talking about this solution. Note you have to take G as input for each test case.
Fixing that thing gives you AC
For this test case:

2
2
1 5 1
1 5 2
2
1 5 1
1 5 2

Try to run on this test case to understand why will it give you NZEC.

Traceback (most recent call last):
  File "prog.py", line 6, in <module>
    i,n,f=map(int,input().split())
ValueError: not enough values to unpack (expected 3, got 1)
2 Likes

Linking to the submission might be preferable in this case, as it doesn’t look like it should be an NZEC. But I’m not a Python guy :slight_smile:

1 Like
g = int(input())

should have come after

for i in range(t):

Please read the input format carefully:

The first line of input contains an integer T, denoting the number of test cases. Then T test cases follow.

The first line of each test contains an integer G, denoting the number of games played by Elephant. Each of the following G lines denotes a single game, and contains 3 space separeted integers I, N, Q

It clearly mentions that G should be the first line of input for EACH test case
Also, I went through your code and your logic is wrong so you’ll prolly get WA. SO, check your code again after completely understanding the problem. If you still get WA, ask over here for help

You do not need an extra conditional statement inside the second condition. Look at akshitm16’s code.

2 Likes

oh, yeah. sorry : /
my code was pretty hard-coded cuz i had done this problem long back, when i had just started (and rn i just explained my previous code, didn’t go through the problem again). My apologies