Python Template For emulating online judge

Revision en1, by Vashesh, 2022-11-18 21:22:02

Hi, This is a python template I am using currently. Similar templates are already available in C++ and I wanted one in python. In case anyone wants to use it, here it is :)

import sys
from os import path
def input():
    return sys.stdin.readline().strip()

    
def solve(n,array):
    # YOUR CODE HERE
    pass

def main():
    # testcases = 1 
    
    testcases = int(input()) # multiple testcases
    for _ in range(testcases):
        n = int(input())
        array = list(map(int,input().split()))
        solve(n,array)
        

if __name__ == "__main__":
    if(path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    main()
        

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Vashesh 2022-11-18 21:22:02 784 Initial revision (published)