Submission #3415391


Source Code Expand

import strutils
import sequtils
import algorithm
import math
import queues
import tables
import sets
import logging
import future

const INF* = int(1e18 + 373)

proc readSeq*(): seq[string] = stdin.readLine().strip().split()
proc readSeq*(n: Natural): seq[string] =
  result = newSeq[string](n)
  for i in 0..<n:
    result[i] = stdin.readLine().strip()

proc readInt1*(): int = readSeq().map(parseInt)[0]
proc readInt2*(): (int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1])
proc readInt3*(): (int, int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1], a[2])
proc readInt4*(): (int, int, int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1], a[2], a[3])

type seq2*[T] = seq[seq[T]]
proc newSeq2*[T](n1, n2: Natural): seq2[T] = newSeqWith(n1, newSeq[T](n2))

#------------------------------------------------------------------------------#
type Pos = tuple [ y, x: int ]

proc placeDiamond(a: var seq2[char]; h, w, y, x, r: int; c: char) =
  for dy in (-r + 1)..(r - 1):
    for dx in (-r + 1)..(r - 1):
      let nextY = dy + y
      let nextX = dx + x
      if nextY in 0..<h and nextX in 0..<w and abs(dy) + abs(dx) < r:
        a[nextY][nextX] = c

proc main() =
  var (h, w, d) = readInt3()


  if d mod 2 == 1:
    var a = newSeq2[char](h, w)
    for i in 0..<h:
      a[i].fill('.')
    for i in 0..<h:
      for j in 0..<w:
        a[i][j] = (if (i + j) mod 2 == 0: 'R' else: 'B')
    for i in 0..<h:
      echo a[i].map(it => $it).join()
    return

  let hh = h
  let ww = w
  h = 1500
  w = 1500
  var a = newSeq2[char](h, w)
  for i in 0..<h:
    a[i].fill('.')

  let r = d div 2
  var q = initQueue[(int, int)]()
  q.enqueue((0, 0))

  let dy = @ [  2 * r      , 2 * (r - 1), -2 * r      , -2 * (r - 1) ]
  let dx = @ [ -2 * (r - 1), 2 * r      ,  2 * (r - 1), -2 * r       ]

  placeDiamond(a, h, w, 0          , 0              , r, 'R')
  placeDiamond(a, h, w, 0 - r      , 0 + (r - 1)    , r, 'Y')
  placeDiamond(a, h, w, 0 + (r - 1), 0 + r          , r, 'G')
  placeDiamond(a, h, w, 0 - 1      , 0 + r + (r - 1), r, 'B')

  while q.len() > 0:
    let (y, x) = q.dequeue()

    for k in 0..<4:
      let nextY = y + dy[k]
      let nextX = x + dx[k]
      if nextY in 0..<h and nextX in 0..<w and a[nextY][nextX] == '.':
        q.enqueue((nextY, nextX))
      placeDiamond(a, h, w, nextY          , nextX              , r, 'R')
      placeDiamond(a, h, w, nextY - r      , nextX + (r - 1)    , r, 'Y')
      placeDiamond(a, h, w, nextY + (r - 1), nextX + r          , r, 'G')
      placeDiamond(a, h, w, nextY - 1      , nextX + r + (r - 1), r, 'B')

  for i in 0..<hh:
    for j in 0..<ww:
      stdout.write(a[i + 500][j + 500])
    echo ""

main()

Submission Info

Submission Time
Task D - Four Coloring
User somq14
Language Nim (0.13.0)
Score 0
Code Size 2814 Byte
Status WA
Exec Time 62 ms
Memory 8316 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: sequtils [Processing]
Hint: algorithm [Processing]
Hint: math [Processing]
Hint: times [Processing]
Hint: queues [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: etcpriv [Processing]
Hint: sets [Processing]
Hint: os [Processing]
Hint: posix [Processing]
Hint: logging [Processing]
lib/pure/logging.nim(128, 22) Hint: 'Exception' is declared but not used [XDeclaredButNotUsed]
Hint: future [Processing]
Hint: macros [Processing]
Main.nim(34, 6) Hint: 'Pos' is declared but not used [XDeclaredButNotUsed]
Hint:  [Link]
Hint: operation successful (24885 lines compiled; 2.691 sec total; 25.261MB; Release Build) [SuccessX]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 1
WA × 1
AC × 31
WA × 17
Set Name Test Cases
Sample 0_00.txt, 0_01.txt
All 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt
Case Name Status Exec Time Memory
0_00.txt AC 1 ms 256 KB
0_01.txt WA 59 ms 6268 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 59 ms 6268 KB
1_02.txt AC 1 ms 256 KB
1_03.txt WA 59 ms 6268 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 44 ms 6268 KB
1_06.txt AC 2 ms 380 KB
1_07.txt WA 60 ms 8316 KB
1_08.txt AC 2 ms 380 KB
1_09.txt AC 45 ms 6268 KB
1_10.txt AC 14 ms 4476 KB
1_11.txt WA 62 ms 6524 KB
1_12.txt AC 14 ms 4476 KB
1_13.txt AC 50 ms 6524 KB
1_14.txt AC 11 ms 4476 KB
1_15.txt WA 62 ms 6524 KB
1_16.txt AC 11 ms 4476 KB
1_17.txt WA 55 ms 6524 KB
1_18.txt AC 11 ms 4476 KB
1_19.txt WA 53 ms 6524 KB
1_20.txt AC 13 ms 4476 KB
1_21.txt WA 51 ms 6524 KB
1_22.txt AC 38 ms 6396 KB
1_23.txt AC 11 ms 4476 KB
1_24.txt AC 10 ms 4476 KB
1_25.txt AC 45 ms 6524 KB
1_26.txt AC 42 ms 6396 KB
1_27.txt AC 11 ms 4476 KB
1_28.txt AC 13 ms 4476 KB
1_29.txt WA 43 ms 6396 KB
1_30.txt AC 10 ms 4476 KB
1_31.txt WA 53 ms 6524 KB
1_32.txt WA 44 ms 6524 KB
1_33.txt WA 47 ms 6396 KB
1_34.txt WA 44 ms 6524 KB
1_35.txt WA 43 ms 6524 KB
1_36.txt WA 49 ms 6524 KB
1_37.txt AC 13 ms 4476 KB
1_38.txt WA 46 ms 6524 KB
1_39.txt AC 14 ms 4476 KB
1_40.txt AC 12 ms 4476 KB
1_41.txt AC 14 ms 4476 KB
1_42.txt AC 11 ms 4604 KB
1_43.txt AC 14 ms 4476 KB
1_44.txt WA 40 ms 6524 KB
1_45.txt AC 11 ms 4476 KB