Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description : "DnA_ass10 application root class"
- date : "$Date$"
- revision : "$Revision$"
- class
- APPLICATION
- inherit
- ARGUMENTS
- create
- make
- feature {NONE} -- Initialization
- make
- -- Run application.
- local
- t_fix, t, input_length, i, j: INTEGER
- input_list: LIST[STRING]
- data: ARRAY[INTEGER]
- output: ARRAY[INTEGER]
- dom: DOMINANTS
- do
- create data.make (0, 0)
- io.read_integer
- t_fix := io.last_integer -- first line input (#testcases)
- create output.make (1, t_fix) -- t_fix outputs
- -- For each test case t...
- from t := t_fix until t < 1 loop
- io.put_string ("reading input...%N")
- -- creates an array of arrays 'data', with the input values of instance 't'
- --
- -- read input into input_list
- io.read_line -- second/third/.../t+1 line input
- input_list := io.last_string.split (' ')
- -- create array 'data' of input length
- input_length := 2* (input_list[1].to_integer)
- data.make (0, input_length - 1) -- array for inputs
- -- store inputs in 'data'
- from i := 0 until i >= input_length loop
- data[i] := input_list[i + 2].to_integer
- i := i + 1
- end
- io.put_string ("input read!%N")
- --
- -- inputs of instance 't' are now stored in 'data'
- -- COMPUTATION
- create dom.make_with_values (input_length, data)
- io.put_string ("calculating solution...%N")
- output[t_fix - t + 1] := dom.ans
- io.put_string ("solution found!%N----- ")
- io.put_integer (t_fix - t + 1) io.put_string (" of ") io.put_integer (t_fix)
- io.put_string (" -----%N")
- t := t - 1
- end -- of 't' loop
- -- OUTPUT
- from i := 1 until i > t_fix loop
- io.put_integer (output[i])
- if i < t_fix then
- io.new_line
- end
- i := i + 1
- end
- end -- of 'make'
- end -- of 'APPLICATION'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement