您好,提交代码时,我一直遇到此NZEC错误。我尽力解决了这个问题,但是我只是不知道出了什么问题。
这里是question 这是一个标题为“ Monk and Rotation” 的标题,我会粘贴直接链接,但问题索引或问题本身的网址都不会改变
TestCases=int(input())
for i in range(TestCases):
InputArray=[]
RotatedArray=[]
#Preprocessing start
params=input()#obtaining parameters for list
length=int(params[0])
rotations=int(params[2])
elements=input()
j=0
while j<=len(elements): #Convert and Loading the elements into actual list
temp=int(elements[j])
InputArray.append(temp)
j=j+2
#end of preprocessing
#start of reducing number of rotations if they exceed list length
while(rotations>=len(InputArray)):
rotations=rotations-len(InputArray)
#end
j=0
for j in range(len(InputArray)):
temp=InputArray[j-rotations]
RotatedArray.append(temp)
j=0
print(*RotatedArray,sep=" ")
#start of deleting the lists used
del InputArray[:]
del InputArray
del RotatedArray[:]
del RotatedArray
#del elements[:]
#del elements
#end
示例输入
1
5 2
1 2 3 4 5
示例输出
4 5 1 2 3
当我提交代码时,测试计算机会随机检测到其第一次或第二次运行正确,而其余的则返回NZEC错误
我不确定出什么问题,我知道我没有得到负索引调用,因为我确定转数不超过数组的长度。至于内存,如您在最后6行中看到的那样,我添加了“ del”语句以强制清除列表。
尽管出于某种原因,当我还清除“ elements”字符串时,所有测试计算机的输入均出现NZEC错误,因此我不确定。
我已经用自己的输入从记事本复制并粘贴了多达10个测试用例来测试了代码,并且所有这些都顺利通过了。
我做错了什么,这些在线测试仪甚至如何使用这些输入进行工作。以及将来如何避免此类问题