#NEWLINE# def check_invalid_autogen_submissions( ) : #NEWLINE# #INDENT# db = api . api . common . get_conn ( ) #NEWLINE# badteams = set ( ) #NEWLINE# cheaters = [ ] #NEWLINE# for problem in api . problem . get_all_problems ( ) : #NEWLINE# #INDENT# good_flags = set ( ) #NEWLINE# if ( ( 'autogen' in problem ) and problem [ 'autogen' ] ) : #NEWLINE# #INDENT# correct_flags = db . submissions . find ( { #NEWLINE# #INDENT# 'pid' : problem [ 'pid' ] , #NEWLINE# 'correct' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# for flag in correct_flags : #NEWLINE# #INDENT# good_flags . add ( flag [ 'key' ] ) #NEWLINE# #UNINDENT# incorrect_flags = db . submissions . find ( { #NEWLINE# #INDENT# 'pid' : problem [ 'pid' ] , #NEWLINE# 'correct' : False , #NEWLINE# #UNINDENT# } ) #NEWLINE# for flag in incorrect_flags : #NEWLINE# #INDENT# if ( flag [ 'key' ] in good_flags ) : #NEWLINE# #INDENT# team = api . team . get_team ( tid = flag [ 'tid' ] ) #NEWLINE# solution = db . submissions . find_one ( { #NEWLINE# #INDENT# 'pid' : problem [ 'pid' ] , #NEWLINE# 'tid' : flag [ 'tid' ] , #NEWLINE# 'correct' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( team [ 'eligible' ] and ( team [ 'tid' ] not in badteams ) ) : #NEWLINE# #INDENT# if ( solution is None ) : #NEWLINE# #INDENT# cheaters . append ( ( problem [ 'team_name' ] , get_score ( tid = flag [ 'tid' ] ) , problem [ 'name' ] , flag [ 'key' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cheaters . append ( ( team [ 'team_name' ] , get_score ( tid = flag [ 'tid' ] ) , problem [ 'name' ] , flag [ 'key' ] , solution [ 'key' ] ) ) #NEWLINE# #UNINDENT# badteams . add ( team [ 'tid' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# print ( '\n' . join ( [ str ( x ) for x in sorted ( cheaters , key = ( lambda x : x [ 1 ] ) , reverse = True ) ] ) )