結果
問題 | No.3 ビットすごろく |
ユーザー |
|
提出日時 | 2021-01-03 15:38:17 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 820 bytes |
コンパイル時間 | 13,738 ms |
コンパイル使用メモリ | 237,124 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 09:01:12 |
合計ジャッジ時間 | 12,226 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
package mainimport ("fmt""strconv")func scan() (N int) {fmt.Scan(&N)return}func countBit(i int) (count int) {s := strconv.FormatInt(int64(i), 2)for _, c := range s {if c == '1' {count++}}return count}func getCount(i int, matrix []bool, N int, count int) int {if i == N {return count}if i < 1 || i > N || matrix[i] == true {return -1}count++matrix[i] = truestep := countBit(i)fowardStep := i + stepbackwardStep := i - stepfowardCount := getCount(fowardStep, matrix, N, count)backwardCount := getCount(backwardStep, matrix, N, count)if fowardCount > backwardCount {return fowardCount} else {return backwardCount}}func main() {var N intN = scan()// N = 11matrix := make([]bool, N)res := getCount(1, matrix, N, 1)fmt.Print(res)}