結果

問題 No.5005 3-SAT
ユーザー ID 21712
提出日時 2025-02-04 03:27:56
言語 Go
(1.23.4)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 19,065 ms
コンパイル使用メモリ 231,700 KB
実行使用メモリ 5,248 KB
スコア 17,782
最終ジャッジ日時 2025-02-04 03:28:25
合計ジャッジ時間 21,457 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import . "fmt"

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 = 255-c.a,255-c.b,255-c.c
	return nil
}

func main() {
	conds := make([]*Cond, 2048)
	for i := range conds {
		conds[i] = new(Cond)
		Scan(conds[i])
	}
	
	ans := make([]int, 256)
	filled := make([]bool, 256)
	
	for _, 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
		}
		if !filled[c.a] {
			ans[c.a] = c.p
			filled[c.a] = true
			continue
		}
		if !filled[c.b] {
			ans[c.b] = c.q
			filled[c.b] = true
			continue
		}
		if !filled[c.c] {
			ans[c.c] = c.r
			filled[c.c] = true
			continue
		}
		break
	}

	for _, x := range ans {
		Print(x)
	}
	Println()
}
0