結果

問題 No.133 カードゲーム
コンテスト
ユーザー illumination-k
提出日時 2019-12-13 00:14:50
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 724 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,563 ms
コンパイル使用メモリ 71,968 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-12 12:35:10
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import strutils, sequtils, algorithm

let N = stdin.readline.parseInt

var
    A = stdin.readLine.split.map(parseInt).sorted()
    B = stdin.readLine.split.map(parseInt).sorted()
    aPerm = newSeq[seq[int]]()
    bPerm = newSeq[seq[int]]()
    cnt = 0
    general_aWin = 0

while true:
    aPerm.add(A)
    if A.nextPermutation() == false: break

while true:
    bPerm.add(B)
    if B.nextPermutation() == false: break

for a in aPerm:
    for b in bPerm:
        inc cnt
        var
            aWin = 0
            bWin = 0
        for i in 0..<N:
            if a[i] > b[i]:
                inc aWin
            else:
                inc bWin

        if aWin > bWin:
            inc general_aWin


echo general_aWin/cnt
0