You are viewing a single comment's thread. Return to all comments →
Then I found this code and it works! Is it because of array module or something?
import os import array if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') n, m = [int(s) for s in input().split()] a = array.array('i', [int(s) for s in input().split()]) for _ in range(m): t, i, j = [int(s) for s in input().split()] if t == 1: a = a[i-1:j] + a[:i-1] + a[j:] else: a = a[:i-1] + a[j:] + a[i-1:j] fptr.write(f'{abs(a[0] - a[-1])}\n') fptr.write(' '.join([str(aa) for aa in a])) fptr.write('\n') fptr.close()
Seems like cookies are disabled on this browser, please enable them to open this website
Array and simple queries
You are viewing a single comment's thread. Return to all comments →
Then I found this code and it works! Is it because of array module or something?