#29597: 我找不到問題.py


Super487 (Super487)

學校 : 國立交通大學
編號 : 182269
來源 : [140.113.92.29]
最後登入時間 :
2023-12-26 20:22:51
a130. 12015 - Google is Feeling Lucky -- UVa12015 | From: [220.141.4.148] | 發表日期 : 2022-03-13 14:46

#0: 100% WA (line:12)

您共輸出 11 行

while True:

  try:

    n = int(input())

    for z in range(n):

      data = []

      for time_10 in range(10):

        website, comment = input().split(' ')

        data.append([website, int(comment)])

 

      data.sort(reverse=True, key = lambda x: x[1]) # 把推薦數最高的排前面

      index = 0

      print(f'Case #{z+1}:')

      while True:

        print(data[index][0]) 

        if data[index][1] > data[index+1][1]: break # 如果下一個推薦數字比前一個小就跳出

        index = index + 1

  except:

    break

 

另外問個問題,為什麼ZeroJudge不給我們測資啊

 
#29602: Re:我找不到問題.py


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a130. 12015 - Google is Feeling Lucky -- UVa12015 | From: [27.247.4.185] | 發表日期 : 2022-03-13 20:07

#0: 100% WA (line:12)

您共輸出 11 行

while True:

  try:

    n = int(input())

    for z in range(n):

      data = []

      for time_10 in range(10):

        website, comment = input().split(' ')

        data.append([website, int(comment)])

 

      data.sort(reverse=True, key = lambda x: x[1]) # 把推薦數最高的排前面

      index = 0

      print(f'Case #{z+1}:')

      while True:

        print(data[index][0]) 

        if data[index][1] > data[index+1][1]: break # 如果下一個推薦數字比前一個小就跳出

        index = index + 1

  except:

    break

 

另外問個問題,為什麼ZeroJudge不給我們測資啊

先把except改掉吧,如果相關度都一樣會超出範圍


您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Traceback (most recent call last):
  File "/9258241/code_9258241.py", line 14, in
    if data[index][1] > data[index + 1][1]: break  # 如果下一個推薦數字比前一個小就跳出
IndexError: list index out of range

 
ZeroJudge Forum