結果
| 問題 |
No.5005 3-SAT
|
| ユーザー |
ID 21712
|
| 提出日時 | 2025-02-04 03:36:31 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 1,302 bytes |
| コンパイル時間 | 13,127 ms |
| コンパイル使用メモリ | 242,424 KB |
| 実行使用メモリ | 6,016 KB |
| スコア | 39,267 |
| 最終ジャッジ日時 | 2025-02-04 03:37:00 |
| 合計ジャッジ時間 | 23,653 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
package main
import . "fmt"
import "math/rand"
const (
N = 2048
M = 256
)
type Cond struct {
a,b,c,p,q,r int
}
func (c *Cond)Scan(s ScanState, v rune) error {
Fscan(s, &c.a, &c.b, &c.c, &c.p, &c.q, &c.r)
c.a,c.b,c.c = M-1-c.a,M-1-c.b,M-1-c.c
return nil
}
func main() {
conds := make([]*Cond, N)
for i := range conds {
conds[i] = new(Cond)
Scan(conds[i])
}
ans := make([]int, M)
best := 0
for i := 0; i < 1000; i++ {
tmp, score := fill(conds)
if score > best {
ans,best = tmp,score
}
}
for _, x := range ans {
Print(x)
}
Println()
}
func fill(conds []*Cond) (ans []int, score int) {
ans = make([]int, M)
filled := make([]bool, M)
score = N
block1:
for i, c := range conds {
if filled[c.a] && ans[c.a] == c.p {
continue
}
if filled[c.b] && ans[c.b] == c.q {
continue
}
if filled[c.c] && ans[c.c] == c.r {
continue
}
for _, x := range rand.Perm(3) {
switch x {
case 0:
if !filled[c.a] {
ans[c.a] = c.p
filled[c.a] = true
continue block1
}
case 1:
if !filled[c.b] {
ans[c.b] = c.q
filled[c.b] = true
continue block1
}
case 2:
if !filled[c.c] {
ans[c.c] = c.r
filled[c.c] = true
continue block1
}
}
}
score = i
break
}
return
}
ID 21712