Kostya the sculptor
Title Link: Http://codeforces.com/problemset/problem/733/D
Greedy
The second small edge for the first keyword, the largest edge is the second keyword, the minimum edge for the third keyword sort, each time only need to find a small edge and the largest edge are the same, the smallest side of the largest two.
Because there are many problems with Python, slice operation A[i:j] is left closed right open interval [i,j)
The code is as follows:
1n =int (input ())2A = []3Ans,u,v = 0,-1,-14 forIinchrange (n):5t = [Int (x) forXinchinput (). Split ()]6 T.sort ()7 ifAns <T[0]:8Ans =T[0]9U = v =ITen t.append (i) One a.append (t) A - fromoperatorImportItemgetter -A.sort (Key=itemgetter (1,2,0), reverse=True) the -i =0 - whileI+1 <N: - ifA[i][1:3]==a[i+1][1:3]: +t = min (a[i][0]+a[i+1][0],a[i][1]) - ifAns <T: +Ans =T AU = a[i][3] atv = a[i+1][3] -i + = 1 - while(i==0orA[i][1:3]==a[i-1][1:3]) andi+1<Len (a): -i + = 1 - - ifU = =V: in Print(1) - Print(u+1) to Else: + Print(2) - Print(u+1,v+1)
Kostya the sculptor