直接笨方法
# -*- coding:utf-8 -*- class CatDogAsylum: def asylum(self, ope): # write code here result=[] enter=[] for temp in ope: if temp[0]==1: enter.append(temp) if temp[0]==2: if temp[1]==0: result.append(enter[0][1]) del[enter[0]] else: if temp[1]==1: for iii in enter: if iii[1]>0: result.append(iii[1]) enter.remove(iii) break if temp[1]==-1: for jjj in enter: if jjj[1]<0: result.append(jjj[1]) enter.remove(jjj) break return result