소풍 문제 런타임 에러 (파이썬)

  • zeroion
    zeroion

    현재상황

    소풍 문제에서 런타임 에러가 나는데 어디서 나는지 모르겠습니다.

    파이썬으로 작성하였습니다.

    #-*- coding: utf-8 -*-
    
    def case_finder(rested_list, decided_list, relations_list):
    
      if len(rested_list) == 0:
        return 1
    
      min_elem = min(rested_list)
      rested_list.remove(min_elem)
      decided_list.append(min_elem)
      r = 0
      for elem in rested_list:
        flag = False
        for relation in relations_list:
          if relation[0] == min_elem and relation[1] == elem:
            flag = True
        if flag == True:
          new_rested_list = rested_list[:]
          new_rested_list.remove(elem)
          new_decided_list = decided_list[:]
          new_decided_list.append(elem)
          r += case_finder(new_rested_list, new_decided_list, relations_list)
    
      return r
    
    case_length = int(raw_input())
    for i in xrange(case_length):
      students_length, relations_length = map(int, raw_input().split(' '))
      relations_input_arr = map(int, raw_input().split(' '))
      relations_list = []
      for j in xrange(0, relations_length * 2, 2):
        min_stu = min(int(relations_input_arr[j]), int(relations_input_arr[j+1]))
        max_stu = max(int(relations_input_arr[j]), int(relations_input_arr[j+1]))
        relations_list.append([min_stu, max_stu])
    
      print case_finder(range(students_length), [], relations_list)
    

    시도

    구조를 다음 처럼 굉장히 단순히 해봐도 에러가 나네요. ㅜㅜ

    #-*- coding: utf-8 -*-
    
    case_length = int(raw_input())
    for i in xrange(case_length):
      students_length, relations_length = map(int, raw_input().split(' '))
      relations_input_arr = map(int, raw_input().split(' '))  
      print 3
    

    9년 전
0개의 댓글이 있습니다.
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.