結果

問題 No.5005 3-SAT
ユーザー nikumakare
提出日時 2024-07-22 20:39:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 622 ms / 2,000 ms
コード長 951 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 77,696 KB
スコア 31,859
最終ジャッジ日時 2024-07-22 20:40:18
合計ジャッジ時間 48,161 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
import sys


def make_testcase():
    C = []
    for i in range(2048):
        C.append([int(i) for i in input().split()])

        # sub = []
        # for j in range(3):
        #     sub.append(random.randrange(256))
        #     sub.append(random.randint(0, 1))
        # C.append(sub[:])
    return C


C = make_testcase()

k = 0
nowans = k
nowscore = 0

table = [C[0]]
# print(table)
ends = 3
while 1:
    if ends == 0:
        break
    ends -= 1
    for row in table:
        if k >> row[0] & 1 == row[3]:
            continue
        if k >> row[1] & 1 == row[4]:
            continue
        if k >> row[2] & 1 == row[5]:
            continue

        tar = random.choice(row[:3])
        k ^= 1 << tar
        break
    else:
        nowscore += 1
        nowans = k
        # print(f"score={nowscore} sol={bin(k)[2:]}", file=sys.stderr)
        table.append(C[nowscore])
        ends = 6 * (nowscore + 1)

print(bin(k)[2:])
0