結果
| 問題 |
No.8042 本棚
|
| コンテスト | |
| ユーザー |
nadeshino
|
| 提出日時 | 2019-04-01 21:21:06 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,423 bytes |
| コンパイル時間 | 1,444 ms |
| コンパイル使用メモリ | 79,564 KB |
| 最終ジャッジ日時 | 2024-11-14 21:23:17 |
| 合計ジャッジ時間 | 1,827 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
stack trace: (most recent call last) Main.nim(6, 9) unpack /home/judge/data/code/Main.nim(25, 14) template/generic instantiation of `input` from here /home/judge/data/code/Main.nim(18, 43) template/generic instantiation of `unpack` from here /home/judge/data/code/Main.nim(6, 9) Error: index 1 not in 0 .. 0
ソースコード
import algorithm, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode
macro unpack*(rhs: seq, cnt: static[int]): auto =
let t = genSym(); result = quote do:(let `t` = `rhs`;())
if NimMinor <= 17:
for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
else:
for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
template input*(typ: typedesc, cnt: Natural = 0): untyped =
let line = stdin.readLine.split(" ")
when cnt == 0:
when typ is int: line.map(parseInt)
elif typ is float: line.map(parseFloat)
elif typ is string: line
elif typ is char: line.mapIt(it[0])
else:
when typ is int: line.map(parseInt).unpack(cnt)
elif typ is float: line.map(parseFloat).unpack(cnt)
elif typ is string: line.unpack(cnt)
elif typ is char: line.mapIt(it[0]).unpack(cnt)
# -------------------------------------------------- #
var N = input(int, 1)
var S = newseq[string]()
var id = inittable[string, int]()
for i in 1..N:
var data = input(string)
S.add(data[0])
if not id.haskey(data[0]): id[data[0]] = 0
case data[1]
of "iti": id[data[0]] += 8
of "ni": id[data[0]] += 4
of "san": id[data[0]] += 2
of "yon": id[data[0]] += 1
S = S.deduplicate()
S.sort(cmp)
for s in S:
if (id[s] and 8) == 8:
echo s, " iti"
if (id[s] and 4) == 4:
echo s, " ni"
if (id[s] and 2) == 2:
echo s, " san"
if (id[s] and 1) == 1:
echo s, " yon"
nadeshino