結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2015-12-29 13:57:14 |
言語 | Nim (2.2.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,886 bytes |
コンパイル時間 | 1,218 ms |
コンパイル使用メモリ | 76,948 KB |
最終ジャッジ日時 | 2024-11-14 19:31:50 |
合計ジャッジ時間 | 1,671 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(18, 18) Error: type mismatch Expression: <624 [1] 624: int Expected one of (first mismatch at [position]): [1] proc `<`(a, b: DateTime): bool [1] proc `<`(a, b: Duration): bool [1] proc `<`(a, b: Time): bool [1] proc `<`(x, y: bool): bool [1] proc `<`(x, y: char): bool [1] proc `<`(x, y: float): bool [1] proc `<`(x, y: float32): bool [1] proc `<`(x, y: int16): bool [1] proc `<`(x, y: int32): bool [1] proc `<`(x, y: int8): bool [1] proc `<`(x, y: pointer): bool [1] proc `<`(x, y: string): bool [1] proc `<`(x, y: uint): bool [1] proc `<`(x, y: uint16): bool [1] proc `<`(x, y: uint32): bool [1] proc `<`(x, y: uint64): bool [1] proc `<`(x, y: uint8): bool [1] proc `<`[A](s, t: HashSet[A]): bool [1] proc `<`[Enum: enum](x, y: Enum): bool [1] proc `<`[T: tuple](x, y: T): bool [1] proc `<`[T](x, y: ptr T): bool [1] proc `<`[T](x, y: ref T): bool [1] proc `<`[T](x, y: set[T]): bool [2] proc `<`(x, y: int): bool [2] proc `<`(x, y: int64): bool
ソースコード
import strutils, sequtils, math, sets, timesvar start = cpuTime()constN: int = 624M: int = 397MATRIX_A: cuint = 0x9908b0df.cuintUPPER_MASK: cuint = 0x80000000.cuintLOWER_MASK: cuint = 0x7fffffff.cuintvarmt = newSeq[cuint](0)mti: int = N + 1proc init_genrand(s: cuint) =mt.add(s and 0xffffffff.cuint)for mti in 1.. <N:mt.add(1812433253.cuint * (mt[mti-1] xor (mt[mti-1] shr 30)).cuint + mti.cuint)mt[mti] = mt[mti] and 0xffffffff.cuintproc init_by_array(init_key: seq[cuint]) =var key_length = init_key.leninit_genrand(19921223)vari = 1j = 0k = if N > key_length: N else: key_lengthwhile k > 0:mt[i] = (mt[i] xor ((mt[i-1] xor (mt[i-1] shr 30)) * 1664525.cuint)) + init_key[j].cuint + j.cuintmt[i] = mt[i] and 0xffffffff.cuinti += 1j += 1if i >= N:mt[0] = mt[N-1]i = 1if j >= key_length:j = 0k -= 1for k in countdown(N-1, 1):mt[i] = (mt[i] xor ((mt[i-1] xor (mt[i-1] shr 30)) * 1566083941.cuint)) - i.cuintmt[i] = mt[i] and 0xffffffff.cuinti += 1if i >= N:mt[0] = mt[N-1]i = 1mt[0] = 0x80000000.cuintproc genrand_int32():cuint =var y: cuintvar mag01 = newSeq[cuint](2)mag01[0] = 0x0mag01[1] = MATRIX_Aif mti.int >= N:if mti == N+1:init_genrand(5489)for kk in 0.. N-M-1:y = (mt[kk] and UPPER_MASK) or (mt[kk+1] and LOWER_MASK)mt[kk] = mt[kk+M] xor (y shr 1) xor mag01[(y and 0x1).int]for kk in N-M.. N-2:y = (mt[kk] and UPPER_MASK) or (mt[kk+1] and LOWER_MASK)mt[kk] = mt[kk+(M-N)] xor (y shr 1) xor mag01[(y and 0x1).int]y = (mt[N-1] and UPPER_MASK) or (mt[0] and LOWER_MASK)mt[N-1] = mt[M-1] xor (y shr 1) xor mag01[(y and 0x1).int]mti = 0y = mt[mti.int]mti += 1y = y xor (y shr 11)y = y xor (y shl 7) and 0x9d2c5680.cuinty = y xor (y shl 15) and 0xefc60000.cuinty = y xor (y shr 18)return yproc genrand_int31():int =return (genrand_int32() shr 1).intproc myrand:int = return genrand_int31()proc shuffle*(arr: var seq) =var koko: int = arr.lenfor i in 0.. <koko:let j = genrand_int31() mod kokoswap arr[i], arr[j]proc shuffled*(arr: var seq):seq =result = arrshuffle(result)###var init = newSeq[cuint](0)init.add(1234)init.add(2345)init.add(3456)init.add(7809)init.add(1131)init.add(epochTime().cuint)init_by_array(init)varn = stdin.readLine.parseInta = stdin.readLine.split.map(parseInt)b = stdin.readLine.split.map(parseInt)check: int = 0all: int = 0while cpuTime() - start < 4.8:all += 1var A = shuffled(a)var B = shuffled(b)varwin: int = 0lose: int = 0for ele in zip(A, B):if ele.a > ele.b:win += 1elif ele.a < ele.b:lose += 1if win > lose:check += 1echo check / all