結果
問題 | No.305 鍵(2) |
ユーザー | tsuchinaga |
提出日時 | 2019-04-12 10:10:19 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 1,217 bytes |
コンパイル時間 | 17,938 ms |
コンパイル使用メモリ | 203,668 KB |
実行使用メモリ | 24,324 KB |
平均クエリ数 | 26.54 |
最終ジャッジ日時 | 2023-09-24 02:13:07 |
合計ジャッジ時間 | 20,004 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
23,664 KB |
testcase_01 | AC | 25 ms
23,640 KB |
testcase_02 | AC | 26 ms
23,856 KB |
testcase_03 | AC | 26 ms
23,364 KB |
testcase_04 | AC | 26 ms
23,808 KB |
testcase_05 | AC | 25 ms
24,324 KB |
testcase_06 | AC | 25 ms
23,520 KB |
testcase_07 | AC | 26 ms
23,424 KB |
testcase_08 | AC | 25 ms
23,352 KB |
testcase_09 | AC | 27 ms
24,036 KB |
testcase_10 | AC | 26 ms
23,844 KB |
testcase_11 | AC | 26 ms
24,048 KB |
testcase_12 | AC | 27 ms
23,628 KB |
ソースコード
package main import ( "fmt" "strconv" "strings" ) func main() { var x int var s string // 全部0~全部9を試して、各数字の個数を探す nums := make([]int, 10) for i := 0; i <= 9; i++ { fmt.Println(strings.Repeat(strconv.Itoa(i), 10)) _, _ = fmt.Scan(&x, &s) if s == "unlocked" { return } nums[i] = x } // fmt.Println(nums) // 1番当たりに近いのを取り出しておく max := nums[0] ans := make([]int, 10) for i := 1; i <= 9; i++ { if max < nums[i] { max = nums[i] for j := range ans { ans[j] = i } } } // fmt.Println(ans) // 先頭から変えながらmaxを増えるよう調整する for i := 0; i <= 9; i++ { for j, a := range nums { if a == 0 { continue } tmp := make([]int, 10) copy(tmp, ans) tmp[i] = j print305(tmp) _, _ = fmt.Scan(&x, &s) if s == "unlocked" { return } if max > x { // 減ったなら、元のが正解 break } else if max < x { // 増えたなら、選んだのが正解 max++ ans[i] = j break } } nums[ans[i]]-- // fmt.Println(i, max, nums, ans) } } func print305(nums []int) { for _, n := range nums { fmt.Print(n) } fmt.Println() }