Submission #4039027


Source Code Expand

from sequtils import map, mapIt
from strutils import split, parseInt, parseFloat

import macros
macro unpack*(input: seq; count: static[int]): untyped =
  result = quote do: ()
  when NimMinor <= 13:
    for i in 0..<count: result[0].add quote do: `input`[`i`]
  else:
    for i in 0..<count: result.add quote do: `input`[`i`]

## count == 0 のとき unpackしない(seq)
## count >  0 のとき count個分 unpack した結果の tuple を返す
type UnselectableTypeError = object of Exception
template input*(typ: typedesc; count: Natural = 0): untyped =
  let line = stdin.readLine.split
  when count == 0:
    when typ is int:    line.map(parseInt)
    elif typ is float:  line.map(parseFloat)
    elif typ is string: line
    else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string")
  else:
    when typ is int:    line.map(parseInt).unpack(count)
    elif typ is float:  line.map(parseFloat).unpack(count)
    elif typ is string: line.unpack(count)
    else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string")

template inputs*(typ: typedesc; count = 0; rows = 1): untyped =
  (1..rows).mapIt(input(typ, count))

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
template secretEcho*(x: varargs[string, `$`]) =
  for v in x:
    stderr.write(v)
  stderr.writeLine ""

template secretEcho*[T](x: seq[seq[T]]) =
  for v in x: secretEcho v

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
let
  grid = @[input(int), input(int), input(int)]

var t = grid
for i, _ in grid:
  for j, _ in grid[i]:
    t[i][j] = grid[j][i]

var
  a: array[3, int]
  b: array[3, int]

for i, row in grid:
  a[i] = row.min

for i, col in t:
  if col[0] - a[0] == col[1] - a[1] and col[1] - a[1] == col[2] - a[2]:
    b[i] = col[0] - a[0]
  else:
    echo "No"
    quit()

echo "Yes"

Submission Info

Submission Time
Task C - Takahashi's Information
User nimon
Language Nim (0.13.0)
Score 300
Code Size 1967 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: sequtils [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: macros [Processing]
Hint:  [Link]
Hint: operation successful (13915 lines compiled; 1.927 sec total; 15.153MB; Release Build) [SuccessX]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 24
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
Case Name Status Exec Time Memory
in01.txt AC 1 ms 256 KB
in02.txt AC 1 ms 256 KB
in03.txt AC 1 ms 256 KB
in04.txt AC 1 ms 256 KB
in05.txt AC 1 ms 256 KB
in06.txt AC 1 ms 256 KB
in07.txt AC 1 ms 256 KB
in08.txt AC 1 ms 256 KB
in09.txt AC 1 ms 256 KB
in10.txt AC 1 ms 256 KB
in11.txt AC 1 ms 256 KB
in12.txt AC 1 ms 256 KB
in13.txt AC 1 ms 256 KB
in14.txt AC 1 ms 256 KB
in15.txt AC 1 ms 256 KB
in16.txt AC 1 ms 256 KB
in17.txt AC 1 ms 256 KB
in18.txt AC 1 ms 256 KB
in19.txt AC 1 ms 256 KB
in20.txt AC 1 ms 256 KB
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB
sample_4.txt AC 1 ms 256 KB