import algorithm, future, macros, math, sequtils, sets, strutils, tables macro unpack(rhs: seq, cnt: static[int]): auto = let v = genSym(); result = quote do:(let `v` = `rhs`;()) if NimMinor <= 17: for i in 0..?=`(n: var SomeNumber, m: SomeNumber) = n = max(n, m) proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2)) proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3))) # -------------------------------------------------- # var (H, W) = input(int, 2) var A = newseq[string](H + 1) for i in 1 .. H: A[i] = "#" & input(string) var tate, yoko = false for i in 1 .. H: var allSame = true for j in 1 .. W - 1: if A[i][j] != A[i][j + 1]: allSame = false if allSame: yoko = true for j in 1 .. W: var allSame = true for i in 1 .. H - 1: if A[i][j] != A[i + 1][j]: allSame = false if allSame: tate = true if yoko and tate: echo "NO" else: echo "YES"