結果

問題 No.2929 Miracle Branch
ユーザー kemunikukemuniku
提出日時 2024-10-12 15:44:19
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 4,876 bytes
コンパイル時間 3,994 ms
コンパイル使用メモリ 76,016 KB
実行使用メモリ 13,940 KB
最終ジャッジ日時 2024-10-12 15:44:43
合計ジャッジ時間 12,479 ms
ジャッジサーバーID
(参考情報)
judge1 / judge
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 4 ms
6,816 KB
testcase_02 AC 3 ms
6,820 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
6,816 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 4 ms
6,816 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 5 ms
6,816 KB
testcase_19 AC 6 ms
6,816 KB
testcase_20 WA -
testcase_21 AC 15 ms
6,816 KB
testcase_22 AC 4 ms
6,820 KB
testcase_23 AC 24 ms
6,820 KB
testcase_24 AC 105 ms
6,816 KB
testcase_25 AC 13 ms
6,820 KB
testcase_26 WA -
testcase_27 AC 4 ms
6,816 KB
testcase_28 AC 3 ms
6,816 KB
testcase_29 AC 3 ms
6,816 KB
testcase_30 AC 4 ms
6,820 KB
testcase_31 AC 4 ms
6,816 KB
testcase_32 AC 3 ms
6,816 KB
testcase_33 AC 4 ms
6,820 KB
testcase_34 AC 267 ms
13,732 KB
testcase_35 AC 261 ms
13,760 KB
testcase_36 AC 3 ms
6,816 KB
testcase_37 AC 286 ms
13,652 KB
testcase_38 AC 286 ms
13,940 KB
testcase_39 AC 293 ms
13,712 KB
testcase_40 AC 269 ms
13,656 KB
testcase_41 AC 272 ms
13,736 KB
testcase_42 AC 284 ms
13,740 KB
testcase_43 AC 270 ms
13,804 KB
testcase_44 AC 299 ms
13,664 KB
testcase_45 AC 4 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import macros;macro ImportExpand(s:untyped):untyped = parseStmt($s[2])
ImportExpand "cplib/tmpl/sheep.nim" <=== "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':\n                break\n            result &= c\n    #chmin,chmax\n    template `max=`(x, y) = x = max(x, y)\n    template `min=`(x, y) = x = min(x, y)\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    #[ include cplib/utils/constants ]#\n    when not declared CPLIB_UTILS_CONSTANTS:\n        const CPLIB_UTILS_CONSTANTS* = 1\n        const INF32*: int32 = 100100111.int32\n        const INF64*: int = int(3300300300300300491)\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"
#茶色のパスに緑をつけいく
#なんか10^18の素因数分解を求められていないか?
#冷静になると、2*10^5以上の素数があるなら終わりなのでok
#6とかが微妙にコーナーそうで怖い。
#6の作り方として、2と3を作ると5+2で7頂点、直接作っても7頂点
#大丈夫か~
#4がヤバいかも?
#2*2は6頂点食うが、4をつくるなら5頂点で済む。
#2はなるべく4を作った方が効率がいい?
#8は2*2*2で9頂点、2*4で8頂点,8で9頂点

var X = ii()
var tmp = X
var D : seq[int]
if X == 1:
    echo 2
    echo 1," ",2
    echo "b g"
    quit()

var div2 = 0
while tmp % 2 == 0:
    tmp //= 2
    div2 += 1

for x in 3..(200000):
    if tmp % x == 0:
        tmp //= x
        D.add(x)

if tmp != 1:
    echo -1
    quit()

var need = (div2//2)*5+(div2%2)*3+(len(D)+sum(D))

if need > 200000:
    echo -1
    quit()

var N = need
var edges : seq[(int,int)]
var B = (div2//2)+(div2%2)+len(D)

for i in range(B-1):
    edges.add((i,i+1))

var now = B
for i in range(len(D)):
    for x in range(D[i]):
        edges.add((now,i))
        now += 1


for i in range(len(D),len(D)+(div2//2)):
    for x in range(4):
        edges.add((now,i))
        now += 1

for i in range(len(D)+(div2//2),(div2%2)+len(D)+(div2//2)):
    for x in range(2):
        edges.add((now,i))
        now += 1

var C = newSeqWith(N,'g')
for i in range(B):
    C[i] = 'b'

assert len(edges) == N-1

echo N
for i in range(N-1):
    echo edges[i][0]+1," ",edges[i][1]+1

echo C.join(" ")
0