結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2015-01-23 02:04:36 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 809 bytes |
コンパイル時間 | 13,891 ms |
コンパイル使用メモリ | 227,096 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:28:08 |
合計ジャッジ時間 | 14,121 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
package mainimport ("fmt""sort")var as, bs []intvar awin intfunc dfs(pa, pb int) {n := len(as)if n == 0 {if pa > pb {awin++}return}for i := 0; i < n; i++ {for j := 0; j < n; j++ {sort.Ints(as)sort.Ints(bs)a, b := as[i], bs[j]as[i], as = as[n-1], as[:n-1]bs[j], bs = bs[n-1], bs[:n-1]sort.Ints(as)sort.Ints(bs)if a > b {dfs(pa+1, pb)} else {dfs(pa, pb+1)}as = append(as, a)bs = append(bs, b)}}}func p(n int) int {if n == 0 {return 1}return n * p(n-1)}func main() {var n intfmt.Scan(&n)as, bs = make([]int, n), make([]int, n)for i := 0; i < n; i++ {fmt.Scan(&as[i])}for i := 0; i < n; i++ {fmt.Scan(&bs[i])}dfs(0, 0)fmt.Printf("%f\n", float64(awin)/float64(p(n)*p(n)))}