結果
| 問題 | No.355 数当てゲーム(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-10 02:40:06 |
| 言語 | Go (1.27.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 94 ms / 2,000 ms |
| + 1µs | |
| コード長 | 1,075 bytes |
| 記録 | |
| コンパイル時間 | 9,803 ms |
| コンパイル使用メモリ | 265,324 KB |
| 実行使用メモリ | 9,896 KB |
| 平均クエリ数 | 5.52 |
| 最終ジャッジ日時 | 2026-10-10 02:40:22 |
| 合計ジャッジ時間 | 12,712 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
ソースコード
package main
import (
"fmt"
"log"
)
func checkGuess(guess [4]int, ans [4]int) (int, int) {
cntX, xntY := 0, 0
for i := 0; i < 4; i++ {
if guess[i] == ans[i] {
cntX++
}
for j := 0; j < 4; j++ {
if i != j && guess[i] == ans[j] {
xntY++
}
}
}
return cntX, xntY
}
func main() {
answers := [][4]int{}
for a := 0; a < 10; a++ {
for b := 0; b < 10; b++ {
for c := 0; c < 10; c++ {
for d := 0; d < 10; d++ {
if a != b && a != c && a != d && b != c && b != d && c != d {
answers = append(answers, [4]int{a, b, c, d})
}
}
}
}
}
check := make([]bool, len(answers))
var x, y int
for i := 0; i < len(answers); i++ {
if check[i] {
continue
}
// Guess
fmt.Printf("%d %d %d %d\n", answers[i][0], answers[i][1], answers[i][2], answers[i][3])
fmt.Scan(&x, &y)
if x == 4 {
log.Println("Correct guess!")
break
}
for j := 0; j < len(answers); j++ {
if check[j] {
continue
}
cntX, cntY := checkGuess(answers[i], answers[j])
if cntX != x || cntY != y {
check[j] = true
}
}
}
}