def Judge(contestsubmit): problem = Problem.objects.get(problemID=contestsubmit.problemID) user = User.objects.get(userID=contestsubmit.userID) user_submit = UserSubmit(solution_id=contestsubmit.id, problem_id=contestsubmit.problemID, language=contestsubmit.language, user_id=contestsubmit.userID, program=contestsubmit.code, mem_limit=problem.memoryLimit, time_limit=problem.timeLimit) if contestsubmit.language != 'g++': user_submit.time_limit *= 3 result = main(user_submit) if "result" in result: contestsubmit.status = result['result'] if "codeLength" in result: contestsubmit.codeLength = result['codeLength'] if "take_time" in result: contestsubmit.runTime = result['take_time'] if "take_memory" in result: contestsubmit.memory = result['take_memory'] contestsubmit.save() print contestsubmit.status if contestsubmit.status == "Accepted": if ContestSubmit.objects.filter(contestID=contestsubmit.contestID, userID=user.userID, problemID=contestsubmit.problemID, status="Accepted").count() == 1: user.accepted = user.accepted + 1 if user.acList == None: user.acList = "" #user.acList += str(contestsubmit.problemID) + "," problem.ac = problem.ac + 1 elif contestsubmit.status == "Time Limit Exceeded": problem.tle = problem.tle + 1 elif contestsubmit.status == "Memory Limit Exceeded": problem.mle = problem.mle + 1 elif contestsubmit.status == "Wrong Answer": problem.wa = problem.wa + 1 elif contestsubmit.status == "Runtime Error": problem.re = problem.re + 1 elif contestsubmit.status == "Compile Error": problem.ce = problem.ce + 1 elif contestsubmit.status == "Presentation Error": problem.pe = problem.pe + 1 elif contestsubmit.status == "System Error": problem.se = problem.se + 1 problem.totalSubmission = problem.totalSubmission + 1 user.total = user.total + 1 user.save() problem.save() return contestsubmit.status
def Judge(contestsubmit): problem = Problem.objects.get(problemID = contestsubmit.problemID) user = User.objects.get(userID = contestsubmit.userID) user_submit = UserSubmit( solution_id = contestsubmit.id, problem_id = contestsubmit.problemID, language = contestsubmit.language, user_id = contestsubmit.userID, program = contestsubmit.code, mem_limit = problem.memoryLimit, time_limit = problem.timeLimit ) if contestsubmit.language != 'g++': user_submit.time_limit *= 3 result = main(user_submit) if "result" in result: contestsubmit.status = result['result'] if "codeLength" in result: contestsubmit.codeLength = result['codeLength'] if "take_time" in result: contestsubmit.runTime = result['take_time'] if "take_memory" in result: contestsubmit.memory = result['take_memory'] contestsubmit.save() print contestsubmit.status if contestsubmit.status == "Accepted": if ContestSubmit.objects.filter(contestID = contestsubmit.contestID, userID = user.userID, problemID = contestsubmit.problemID, status = "Accepted").count() == 1: user.accepted = user.accepted + 1 if user.acList == None: user.acList = "" #user.acList += str(contestsubmit.problemID) + "," problem.ac = problem.ac + 1 elif contestsubmit.status == "Time Limit Exceeded": problem.tle = problem.tle + 1 elif contestsubmit.status == "Memory Limit Exceeded": problem.mle = problem.mle + 1 elif contestsubmit.status == "Wrong Answer": problem.wa = problem.wa + 1 elif contestsubmit.status == "Runtime Error": problem.re = problem.re + 1 elif contestsubmit.status == "Compile Error": problem.ce = problem.ce + 1 elif contestsubmit.status == "Presentation Error": problem.pe = problem.pe + 1 elif contestsubmit.status == "System Error": problem.se = problem.se + 1 problem.totalSubmission = problem.totalSubmission + 1 user.total = user.total + 1 user.save() problem.save() return contestsubmit.status