結果
問題 | No.355 数当てゲーム(2) |
ユーザー | yukirin |
提出日時 | 2016-04-02 15:37:38 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 2,295 bytes |
コンパイル時間 | 13,769 ms |
コンパイル使用メモリ | 240,196 KB |
実行使用メモリ | 25,496 KB |
平均クエリ数 | 41.62 |
最終ジャッジ日時 | 2024-07-16 23:27:12 |
合計ジャッジ時間 | 17,929 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,848 KB |
testcase_01 | AC | 25 ms
25,232 KB |
testcase_02 | AC | 25 ms
25,232 KB |
testcase_03 | AC | 26 ms
25,232 KB |
testcase_04 | AC | 25 ms
24,848 KB |
testcase_05 | AC | 25 ms
24,836 KB |
testcase_06 | AC | 24 ms
24,848 KB |
testcase_07 | AC | 23 ms
25,232 KB |
testcase_08 | AC | 24 ms
24,592 KB |
testcase_09 | AC | 24 ms
24,848 KB |
testcase_10 | AC | 24 ms
24,592 KB |
testcase_11 | AC | 25 ms
24,848 KB |
testcase_12 | AC | 25 ms
24,976 KB |
testcase_13 | AC | 26 ms
24,976 KB |
testcase_14 | AC | 24 ms
24,592 KB |
testcase_15 | AC | 25 ms
25,232 KB |
testcase_16 | AC | 24 ms
24,848 KB |
testcase_17 | AC | 24 ms
24,848 KB |
testcase_18 | AC | 24 ms
25,220 KB |
testcase_19 | AC | 24 ms
24,976 KB |
testcase_20 | AC | 25 ms
25,208 KB |
testcase_21 | AC | 25 ms
24,952 KB |
testcase_22 | AC | 24 ms
24,824 KB |
testcase_23 | AC | 24 ms
25,192 KB |
testcase_24 | AC | 24 ms
24,812 KB |
testcase_25 | AC | 25 ms
24,824 KB |
testcase_26 | AC | 25 ms
24,824 KB |
testcase_27 | AC | 25 ms
24,568 KB |
testcase_28 | AC | 26 ms
24,824 KB |
testcase_29 | AC | 25 ms
24,568 KB |
testcase_30 | AC | 25 ms
24,568 KB |
testcase_31 | AC | 25 ms
24,952 KB |
testcase_32 | AC | 25 ms
24,952 KB |
testcase_33 | AC | 25 ms
25,208 KB |
testcase_34 | AC | 24 ms
25,208 KB |
testcase_35 | AC | 24 ms
24,812 KB |
testcase_36 | AC | 26 ms
25,196 KB |
testcase_37 | AC | 24 ms
24,556 KB |
testcase_38 | AC | 24 ms
24,812 KB |
testcase_39 | AC | 25 ms
25,496 KB |
testcase_40 | AC | 26 ms
24,940 KB |
testcase_41 | AC | 25 ms
25,196 KB |
testcase_42 | AC | 25 ms
24,556 KB |
testcase_43 | AC | 25 ms
24,812 KB |
testcase_44 | AC | 24 ms
24,812 KB |
testcase_45 | AC | 26 ms
24,812 KB |
testcase_46 | AC | 25 ms
24,940 KB |
testcase_47 | AC | 24 ms
24,812 KB |
testcase_48 | AC | 26 ms
25,196 KB |
testcase_49 | AC | 26 ms
25,184 KB |
testcase_50 | AC | 25 ms
25,184 KB |
testcase_51 | AC | 23 ms
25,052 KB |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) ns, c1, c2 := first() if c1 == 4 { return } ans, count, all, found := make([]int, 4), 0, false, false for j := 0; count < 2 && j < 5; j++ { for i := 0; i < 10; i++ { if check(ns, i) { continue } tmp := ns[j] ns[j] = i x, y := inOut(ns) ns[j] = tmp if x == 4 { return } if c1+c2 > x+y { ans[count] = tmp count++ break } } } candi := make([]int, 0, 8) for i := 0; i < 10; i++ { if ans[0] == i || ans[1] == i { continue } candi = append(candi, i) } comb(candi, 2, func(nums []int) { if all || found { return } copy(ans[2:4], nums) x, y := inOut(ans) if x == 4 { found = true } if x+y == 4 { all = true } }) perm(ans, 4, func(nums []int) { if found { return } x, _ := inOut(nums) if x == 4 { found = true } }) } func check(ns []int, n int) bool { for _, v := range ns { if n == v { return true } } return false } func first() ([]int, int, int) { nss := [][]int{ {0, 1, 2, 3}, {4, 5, 6, 7}, {6, 7, 8, 9}, } for _, v := range nss { x, y := inOut(v) if x+y >= 2 { return v, x, y } } return nil, 0, 0 } func inOut(ns []int) (int, int) { fmt.Println(ns[0], ns[1], ns[2], ns[3]) os.Stdout.Sync() return nextInt(), nextInt() } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i } func comb(a []int, r int, fn func([]int)) { if r > len(a) || r < 1 { return } var f func([]int, int, int) f = func(ret []int, last, c int) { if c == 0 { fn(ret) return } c-- for i, v := range a[last : len(a)-c] { ret[r-c-1] = v f(ret, i+last+1, c) } } ret := make([]int, r) f(ret, 0, r) } func perm(a []int, r int, fn func([]int)) { permL := make([]int, r) f := func(s []int) { copy(permL, s) k := 1 c := make([]int, r+1) for i := 1; i < len(c); i++ { c[i] = i } for k < r { i := 0 if k&1 == 1 { i = c[k] } permL[k], permL[i] = permL[i], permL[k] fn(permL) for k = 1; c[k] == 0; k++ { c[k] = k } c[k]-- } } if r < 2 { comb(a, r, fn) return } comb(a, r, f) }