import sequtils,times proc printf(formatstr: cstring){.header: "", varargs.} template stopwatch(body) = (let t1 = cpuTime();body;echo "TIME:",(cpuTime() - t1) * 1000,"ms") template stopwatch(body) = body template `+=`(x,y) = x = x + y # GC_disableMarkAndSweep() template useMatrix = type Matrix[T] = ref object w,h:int data: seq[T] proc `[]`[T](m:var Matrix[T],x,y:int):var T {.inline.} = m.data[x + y * m.w] proc `[]=`[T](m:var Matrix[T],x,y:int,val:T) {.inline.} = m.data[x + y * m.w] = val proc newMatrix[T](w,h:int):Matrix[T] = new(result) result.w = w result.h = h result.data = newSeq[T](w * h) proc identityMatrix[T](n:int):Matrix[T] = result = newMatrix[T](n,n) for i in 0.." .} proc scan(): int = var minus = false block: let k = getchar_unlocked() if k == '-' : minus = true else: result = 10 * result + k.ord - '0'.ord while true: let k = getchar_unlocked() if k < '0' or k > '9': break result = 10 * result + k.ord - '0'.ord if minus: result *= -1 stopwatch: let n = scan() let px = scan() let py = scan() var Q = newSeq[int](n) var V = newSeq[int](n) for i in 0..