結果

問題 No.382 シャイな人たち (2)
ユーザー convexineqconvexineq
提出日時 2021-01-10 01:42:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,454 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 101,068 KB
最終ジャッジ日時 2024-04-29 20:04:27
合計ジャッジ時間 18,940 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcountll(i):
    i -= (i >> 1) & 0x5555555555555555
    i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333)
    i = (i & 0x0F0F0F0F0F0F0F0F) + ((i>>4) & 0x0F0F0F0F0F0F0F0F)
    i = (i>>32) + (i & 0xFFFFFFFF)
    return ((i * 0x1010101) & 0xffffffff) >> 24

def popcount128(i):
    return popcountll(i>>62) + popcountll(i&0x3FFFFFFFFFFFFFFF)

def maximum_clique_BK(G):
    def dfs(R, P, cnt):
        nonlocal ans,val
        if popcount(P)+cnt <= val: return # 枝刈り
        if P==0:
            if val < cnt:
                val = cnt
                ans = R
            return
        PP = P&~g[(P&-P).bit_length() - 1]
        while PP:
            v = PP&-PP
            vv = v.bit_length() - 1
            dfs(R|v, P&g[vv], cnt+1)
            P ^= v
            PP ^= v
    
    n = len(G)
    #assert n <= 63
    N = 1<<n
    g = [0]*n
    for a in range(n):
        for b in range(n):
            if G[a][b] == 0 and a != b:
                g[a] ^= 1<<b
    ans = val = 0
    popcount = popcountll if n <= 64 else popcount128
    dfs(R=0, P=N-1, cnt=0)
    return ans,val

s = int(input())
MOD = 1000003
s = s*12345%MOD
n = s%120+2
g = [[0]*n for _ in range(n)]
p = s = s*12345%MOD
for i in range(n):
    for j in range(i+1,n):
        s = s*12345%MOD
        if s >= p:
            g[i][j] = g[j][i] = 1
ans, val = maximum_clique_BK(g)
print(val+1)
ans = [i+1 for i,c in enumerate(bin(ans)[2:][::-1]) if c == "1"]
print(*ans)
0