to_add = [0 for i in ord]  # longest possible path before reaching vertex i
    for i in range(0, len(ord)):
        longest_path = max(longest_path, to_add[i])
        for w in v_out[ord[i]]:
            to_add[ord.index(w)] = max(to_add[ord.index(w)], to_add[i] + 1)
    return longest_path + 1  # +1 because we reached the final vertex


# path to the local test files
path = "testdata/DnA-longest-path/"
input_files = [
    os.path.join(path, file) for file in os.listdir(path)
    if file.endswith(".input")
]
output_files = [
    os.path.join(path, file) for file in os.listdir(path)
    if file.endswith(".output")
]
input_files.sort()
output_files.sort()
# inputs from the test files
inputs = read_input()
# outputs generated by the algorithm
start_time = process_time()
outputs = list()
for input in inputs:
    outputs.append([find_longest_path(case) for case in input])
end_time = process_time()

judge.run(output_files, outputs, end_time - start_time)
Exemplo n.º 2
0
import judge
import sys

if __name__=='__main__':
	pid=sys.argv[1]
	fid="media/"+sys.argv[2]
	lang=sys.argv[3]
	print(judge.run(pid,fid,lang))