以下是我用python寫的程式碼
但是當他在面對詢問的時候
卻一直噴line20:EOF While reading a line
不確定是不是題目在下面詢問的時候
沒有把測資通通一行一行加上\n
能否請管理員協助查看一下
如程式碼上有不周之處也請幫忙指正一下
import copy
import sys
for line in sys.stdin:
line = line.split('\r')[0].split(' ')
team = int(line[0])
number = int(line[1])
quesion = int(line[2])
have = []
for i in range(team):
line = input().split('\r')[0].split(' ')
tmp = []
if '' in line:
line.remove('')
for j in range(1,int(line[0])+1,1):
tmp.append(line[j])
have.append(copy.copy(tmp))
for i in range(quesion):
line = input().split('\r')[0].split(' ') #正式執行這行噴EOF,測試執行就不會
team1 = int(line[0])
team2 = int(line[1])
team1_have = copy.copy(list(have[team1-1]))
team2_have = copy.copy(list(have[team2-1]))
for ele in team1_have:
if ele in team2_have:
team2_have.remove(ele)
team1_have.remove(ele)
print(len(team1_have)*len(team2_have))
測資裡確實少了換行,另外似乎有詢問數不符的問題,
這點還要向出題者確認