結果

問題 No.133 カードゲーム
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-27 16:24:02
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 854 bytes
コンパイル時間 873 ms
コンパイル使用メモリ 65,696 KB
最終ジャッジ日時 2024-04-27 02:47:06
合計ジャッジ時間 1,350 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(20, 12) Error: undeclared identifier: 'lc'

ソースコード

diff #

import future, strutils, algorithm


proc nextString: string =
    result = ""
    while not endOfFile stdin:
        let c = readChar stdin
        if c == ' ' or c == "\n"[0]: break
        elif c != '\r': add result, c


proc nextInt: int =
    parseInt nextString()


let
    n = nextInt()

var
    A, B = lc[nextInt() | (i <- 0 ..< n), int].sorted(cmp)
    win = 0
    cnt = 0

proc fight: void =
    var miniWin = 0
    inc cnt
    for i in 0 ..< n:
        if A[i] > B[i]:
            inc miniWin
        else:
            dec miniWin
    if miniWin > 0:
        inc win


proc main: void =
    fight()
    while B.nextPermutation:
        fight()
    while A.nextPermutation:
        sort(B, cmp)
        fight()
        while B.nextPermutation:
            fight()

    echo((win / cnt).formatFloat(ffDecimal, 2))

when isMainModule:
    main()
0