提出 #74786411
ソースコード 拡げる
import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2])
# source: src/cplib/tmpl/sheep.nim
ImportExpand "cplib/tmpl/sheep" <=== "when not declared CPLIB_TMPL_SHEEP:\n const CPLIB_TMPL_SHEEP* = 1\n {.warning[UnusedImport]: off.}\n {.hint[XDeclaredButNotUsed]: off.}\n import algorithm\n import sequtils\n import tables\n import macros\n import math\n import sets\n import strutils\n import strformat\n import sugar\n import heapqueue\n import streams\n import deques\n import bitops\n import std/lenientops\n import options\n #入力系\n proc scanf(formatstr: cstring){.header: \"<stdio.h>\", varargs.}\n proc getchar(): char {.importc: \"getchar_unlocked\", header: \"<stdio.h>\", discardable.}\n proc ii(): int {.inline.} = scanf(\"%lld\\n\", addr result)\n proc lii(N: int): seq[int] {.inline.} = newSeqWith(N, ii())\n proc si(): string {.inline.} =\n result = \"\"\n var c: char\n while true:\n c = getchar()\n if c == ' ' or c == '\\n' or c == '\\255':\n break\n result &= c\n \n # 出力系\n # 1. 実際の処理を行う proc (openArray を受け取る)\n proc print_internal(prop: tuple[f: File, sepc: string, endc: string, flush: bool], args: openArray[string]) =\n for i in 0 ..< args.len:\n prop.f.write(args[i])\n if i != args.len - 1:\n prop.f.write(prop.sepc)\n else:\n prop.f.write(prop.endc)\n if prop.flush:\n prop.f.flushFile()\n\n # 2. ユーザーが呼び出すためのインターフェース (varargs を受け取る)\n proc print*(prop: tuple[f: File, sepc: string, endc: string, flush: bool], args: varargs[string, `$`]) =\n # varargs は内部では openArray として扱えるので、そのまま渡せる\n print_internal(prop, args)\n\n proc print*(args: varargs[string, `$`]) =\n # こちらも内部用の proc を呼ぶ\n print_internal((f: stdout, sepc: \" \", endc: \"\\n\", flush: false), args)\n macro getSymbolName(x: typed): string = x.toStrLit\n macro debug*(args: varargs[untyped]): untyped =\n when defined(debug):\n result = newNimNode(nnkStmtList, args)\n template prop(e: string = \"\"): untyped = (f: stderr, sepc: \"\", endc: e, flush: true)\n for i, arg in args:\n if arg.kind == nnkStrLit:\n result.add(quote do: print(prop(), \"\\\"\", `arg`, \"\\\"\"))\n else:\n result.add(quote do: print(prop(\": \"), getSymbolName(`arg`)))\n result.add(quote do: print(prop(), `arg`))\n if i != args.len - 1: result.add(quote do: print(prop(), \", \"))\n else: result.add(quote do: print(prop(), \"\\n\"))\n else:\n return (quote do: discard)\n #chmin,chmax\n template `max=`(x, y) = x = max(x, y)\n template `min=`(x, y) = x = min(x, y)\n proc chmin[T](x: var T, y: T):bool=\n if x > y:\n x = y\n return true\n return false\n proc chmax[T](x: var T, y: T):bool=\n if x < y:\n x = y\n return true\n return false\n #bit演算\n proc `%`*(x: int, y: int): int =\n result = x mod y\n if y > 0 and result < 0: result += y\n if y < 0 and result > 0: result += y\n proc `//`*(x: int, y: int): int{.inline.} =\n result = x div y\n if y > 0 and result * y > x: result -= 1\n if y < 0 and result * y < x: result -= 1\n proc `%=`(x: var int, y: int): void = x = x%y\n proc `//=`(x: var int, y: int): void = x = x//y\n proc `**`(x: int, y: int): int = x^y\n proc `**=`(x: var int, y: int): void = x = x^y\n proc `^`(x: int, y: int): int = x xor y\n proc `|`(x: int, y: int): int = x or y\n proc `&`(x: int, y: int): int = x and y\n proc `>>`(x: int, y: int): int = x shr y\n proc `<<`(x: int, y: int): int = x shl y\n proc `~`(x: int): int = not x\n proc `^=`(x: var int, y: int): void = x = x ^ y\n proc `&=`(x: var int, y: int): void = x = x & y\n proc `|=`(x: var int, y: int): void = x = x | y\n proc `>>=`(x: var int, y: int): void = x = x >> y\n proc `<<=`(x: var int, y: int): void = x = x << y\n proc `[]`(x: int, n: int): bool = (x and (1 shl n)) != 0\n #便利な変換\n proc `!`(x: char, a = '0'): int = int(x)-int(a)\n #定数\n when not declared CPLIB_UTILS_CONSTANTS:\n const CPLIB_UTILS_CONSTANTS* = 1\n const INF32*: int32 = 1001000027.int32\n const INF64*: int = int(3300300300300300491)\n \n const INF = INF64\n #converter\n\n #range\n iterator range(start: int, ends: int, step: int): int =\n var i = start\n if step < 0:\n while i > ends:\n yield i\n i += step\n elif step > 0:\n while i < ends:\n yield i\n i += step\n iterator range(ends: int): int = (for i in 0..<ends: yield i)\n iterator range(start: int, ends: int): int = (for i in\n start..<ends: yield i)\n\n #joinが非stringでめちゃくちゃ遅いやつのパッチ\n proc join*[T: not string](a: openArray[T], sep: string = \"\"): string = a.mapit($it).join(sep)\n\n proc dump[T](arr:seq[seq[T]])=\n for i in 0..<len(arr):\n echo arr[i]\n\n proc sum(slice:HSlice[int,int]):int=\n return (slice.a+slice.b)*len(slice)//2\n \n proc `<`[T](l,r:seq[T]):bool=\n for i in 0..<min(len(l),len(r)):\n if l[i] > r[i]:\n return false\n elif l[i] < r[i]:\n return true\n return len(l) < len(r)\n \n # Yes/No\n proc yes*(b: bool = true): void = print(if b: \"Yes\" else: \"No\")\n proc oo*(b: bool = true): void = yes(not b)\n\n proc takahashi(b:bool = true) : void = print(if b: \"Takahashi\" else: \"Aoki\")\n proc aoki(b:bool = true) : void = takahashi(not b)\n\n template dblock(body: untyped) =\n when defined(debug):\n block:\n body\n"
var N = ii()
var A = lii(N)
var idxs = newseq[seq[int]](10**6+1)
for i in range(N):
idxs[A[i]].add(i)
var ans = INF
for i in 0..(10**6):
for k in range(len(idxs[i])-1):
ans.min = idxs[i][k+1]-idxs[i][k]+1
if ans == INF:
echo -1
else:
echo ans
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
300 / 300 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All |
00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-random-001.txt, 01-random-002.txt, 01-random-003.txt, 01-random-004.txt, 01-random-005.txt, 01-random-006.txt, 01-random-007.txt, 01-random-008.txt, 01-random-009.txt, 01-random-010.txt, 01-random-011.txt, 01-random-012.txt, 01-random-013.txt, 01-random-014.txt, 01-random-015.txt, 02-small-001.txt, 02-small-002.txt, 02-small-003.txt, 02-small-004.txt, 02-small-005.txt, 02-small-006.txt, 02-small-007.txt, 02-small-008.txt, 02-small-009.txt, 02-small-010.txt, 02-small-011.txt, 02-small-012.txt, 02-small-013.txt, 02-small-014.txt, 02-small-015.txt, 03-large-001.txt, 03-large-002.txt, 03-large-003.txt, 03-large-004.txt, 03-large-005.txt, 03-large-006.txt, 03-large-007.txt, 03-large-008.txt, 03-large-009.txt, 03-large-010.txt, 03-large-011.txt, 03-large-012.txt, 03-large-013.txt, 03-large-014.txt, 03-large-015.txt, 03-large-016.txt, 03-large-017.txt, 03-large-018.txt, 03-large-019.txt, 03-large-020.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00-sample-001.txt |
AC |
10 ms |
19704 KiB |
| 00-sample-002.txt |
AC |
9 ms |
19632 KiB |
| 00-sample-003.txt |
AC |
8 ms |
19588 KiB |
| 01-random-001.txt |
AC |
24 ms |
23368 KiB |
| 01-random-002.txt |
AC |
24 ms |
23388 KiB |
| 01-random-003.txt |
AC |
20 ms |
23940 KiB |
| 01-random-004.txt |
AC |
26 ms |
23672 KiB |
| 01-random-005.txt |
AC |
26 ms |
23556 KiB |
| 01-random-006.txt |
AC |
22 ms |
25780 KiB |
| 01-random-007.txt |
AC |
29 ms |
24168 KiB |
| 01-random-008.txt |
AC |
28 ms |
24280 KiB |
| 01-random-009.txt |
AC |
22 ms |
26032 KiB |
| 01-random-010.txt |
AC |
14 ms |
20468 KiB |
| 01-random-011.txt |
AC |
13 ms |
20696 KiB |
| 01-random-012.txt |
AC |
13 ms |
20936 KiB |
| 01-random-013.txt |
AC |
13 ms |
20356 KiB |
| 01-random-014.txt |
AC |
13 ms |
20312 KiB |
| 01-random-015.txt |
AC |
11 ms |
20764 KiB |
| 02-small-001.txt |
AC |
9 ms |
19556 KiB |
| 02-small-002.txt |
AC |
9 ms |
19624 KiB |
| 02-small-003.txt |
AC |
9 ms |
19428 KiB |
| 02-small-004.txt |
AC |
9 ms |
19560 KiB |
| 02-small-005.txt |
AC |
9 ms |
19632 KiB |
| 02-small-006.txt |
AC |
8 ms |
19704 KiB |
| 02-small-007.txt |
AC |
9 ms |
19704 KiB |
| 02-small-008.txt |
AC |
9 ms |
19700 KiB |
| 02-small-009.txt |
AC |
9 ms |
19672 KiB |
| 02-small-010.txt |
AC |
10 ms |
19632 KiB |
| 02-small-011.txt |
AC |
10 ms |
19632 KiB |
| 02-small-012.txt |
AC |
10 ms |
19560 KiB |
| 02-small-013.txt |
AC |
9 ms |
19704 KiB |
| 02-small-014.txt |
AC |
10 ms |
19672 KiB |
| 02-small-015.txt |
AC |
9 ms |
19564 KiB |
| 03-large-001.txt |
AC |
30 ms |
24064 KiB |
| 03-large-002.txt |
AC |
30 ms |
24308 KiB |
| 03-large-003.txt |
AC |
29 ms |
24312 KiB |
| 03-large-004.txt |
AC |
23 ms |
26140 KiB |
| 03-large-005.txt |
AC |
31 ms |
24488 KiB |
| 03-large-006.txt |
AC |
29 ms |
24168 KiB |
| 03-large-007.txt |
AC |
28 ms |
24240 KiB |
| 03-large-008.txt |
AC |
23 ms |
26200 KiB |
| 03-large-009.txt |
AC |
30 ms |
24312 KiB |
| 03-large-010.txt |
AC |
32 ms |
24308 KiB |
| 03-large-011.txt |
AC |
30 ms |
24172 KiB |
| 03-large-012.txt |
AC |
24 ms |
25888 KiB |
| 03-large-013.txt |
AC |
29 ms |
24436 KiB |
| 03-large-014.txt |
AC |
28 ms |
24212 KiB |
| 03-large-015.txt |
AC |
30 ms |
24324 KiB |
| 03-large-016.txt |
AC |
23 ms |
26092 KiB |
| 03-large-017.txt |
AC |
30 ms |
24308 KiB |
| 03-large-018.txt |
AC |
29 ms |
24168 KiB |
| 03-large-019.txt |
AC |
30 ms |
24240 KiB |
| 03-large-020.txt |
AC |
23 ms |
26088 KiB |