8.2多多笔试
多多
96+100+100+0
# 10 2 # 6 3 # # 10 4 # 6 3 3 3 # print(list(map(int, input().split()))) [K,N] = list(map(int, input().split())) step = list(map(int, input().split())) dis = K temp_count = 0 flag = 0 for s in step: if dis>s: dis = dis - s elif dis < s: dis = s - dis temp_count += 1 else: dis = s - dis flag = 1 break if flag&nbs***bsp;K==0&nbs***bsp;dis==0: print("paradox") else: print(dis, temp_count)
# 分类 N = int(input()) data = [] for i in range(N): data.append(tuple(map(int,input().split()))) item_nums = 1 item_count = {data[0]:1} def is_cycle(l1,l2): for i in range(4): new_l = l1[i:] + l1[:i] if new_l==l2: return True return False def issame(d1,d2): top_down = (d1[0],d1[1]) l1 = [d1[2],d1[4],d1[3],d1[5]] if (d2[0],d2[1]) == top_down: l2 = [d2[2],d2[4],d2[3],d2[5]] elif (d2[1],d2[0]) == top_down: l2 = [d2[2], d2[4], d2[3], d2[5]][::-1] elif (d2[2],d2[3]) == top_down: l2 = [d2[0],d2[5],d2[1],d2[4]] elif (d2[3],d2[2]) == top_down: l2 = [d2[0], d2[5], d2[1], d2[4]][::-1] elif (d2[4],d2[5]) == top_down: l2 = [d2[0],d2[2],d2[1],d2[3]] elif (d2[5],d2[4]) == top_down: l2 = [d2[0], d2[2], d2[1], d2[3]][::-1] else: return False return is_cycle(l1,l2) for ss in data[1:]: flag = 0 for k in item_count: if issame(ss,k): flag = 1 item_count[k] += 1 break if not flag: item_count[ss] = 1 item_nums += 1 print(item_nums) values = list(item_count.values()) values.sort(reverse=True) print(" ".join(map(str,values)))
[N,M,T] = list(map(int,input().split())) N_info = [] for _ in range(N): N_info.append(list(map(int,input().split()))) M_info = [] for _ in range(M): M_info.append(list(map(int,input().split()))) N_info.append([0,0]) M_info.append([0,0]) # soulution # target = T N_left = 0 M_right = len(M_info)-1 N_info.sort(key=lambda x:x[1]) M_info.sort(key=lambda x:x[1]) import sys min_hot = sys.maxsize N_temp_min_hot = [] temp_min = sys.maxsize for i in range(len(N_info)-1,-1,-1): temp_min = min(temp_min,N_info[i][0]) N_temp_min_hot.append(temp_min) N_temp_min_hot = N_temp_min_hot[::-1] M_temp_min_hot = [] temp_min = sys.maxsize for i in range(len(M_info)-1,-1,-1): temp_min = min(temp_min,M_info[i][0]) M_temp_min_hot.append(temp_min) M_temp_min_hot = M_temp_min_hot[::-1] while N_left<len(N_info) and M_right>=0: N_N = N_info[N_left] M_M = M_info[M_right] if N_N[1] + M_M[1]<T: N_left += 1 else: min_hot = min(min_hot,N_N[0]+M_M[0]) min_hot = min(min_hot,M_M[0]+N_temp_min_hot[N_left]) cur_index = M_right while cur_index>=0 and M_info[cur_index][1]+N_N[1]>=T: cur_index -= 1 if cur_index==0 and N_N[1]>=T: min_hot = min(min_hot,N_N[0]) min_hot = min(min_hot,N_N[0]+M_temp_min_hot[cur_index+1]) M_right -= 1 if min_hot==sys.maxsize: print(-1) else: print(min_hot)
第四题想找构造多个不连通的子图,然后用图着色做,没做出来,花了一个小时得0分,有点气。