#NEWLINE# def convert_input_data( input_data ) : #NEWLINE# #INDENT# lines = input_data . split ( '\n' ) #NEWLINE# N = lines [ 0 ] . split ( ' ' ) [ 0 ] #NEWLINE# M = lines [ 0 ] . split ( ' ' ) [ 1 ] #NEWLINE# f = open ( 'setcover.data' , 'wt' ) #NEWLINE# f . write ( 'data;\n\n' ) #NEWLINE# f . write ( ( ( 'param n := ' + N ) + ';\n' ) ) #NEWLINE# f . write ( ( ( 'param m := ' + M ) + ';\n' ) ) #NEWLINE# f . write ( '\n' ) #NEWLINE# f . write ( 'set E := \n' ) #NEWLINE# cost = [ ] #NEWLINE# for i in xrange ( 1 , ( int ( M ) + 1 ) ) : #NEWLINE# #INDENT# parts = lines [ i ] . split ( ' ' ) #NEWLINE# cost . append ( parts [ 0 ] ) #NEWLINE# for j in xrange ( 1 , len ( parts ) ) : #NEWLINE# #INDENT# f . write ( ( ( '   ' + str ( i ) ) + ' ' ) ) #NEWLINE# f . write ( ( str ( ( int ( parts [ j ] ) + 1 ) ) + '\n' ) ) #NEWLINE# #UNINDENT# #UNINDENT# f . write ( ';\n\n' ) #NEWLINE# f . write ( 'param w:= ' ) #NEWLINE# for i in xrange ( 1 , ( int ( M ) + 1 ) ) : #NEWLINE# #INDENT# f . write ( ( ( ( str ( i ) + ' ' ) + cost [ ( i - 1 ) ] ) + ', ' ) ) #NEWLINE# #UNINDENT# f . write ( ';\n\n' ) #NEWLINE# f . write ( 'end;\n' ) #NEWLINE# f . close ( )