結果

問題 No.1711 Divide LCM
ユーザー tamatotamato
提出日時 2021-10-15 22:57:10
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,028 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 151,632 KB
最終ジャッジ日時 2023-10-17 20:49:56
合計ジャッジ時間 17,304 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
56,044 KB
testcase_01 AC 41 ms
56,044 KB
testcase_02 AC 41 ms
55,980 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 53 ms
63,900 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 74 ms
73,404 KB
testcase_30 RE -
testcase_31 AC 70 ms
73,368 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 68 ms
73,308 KB
testcase_41 AC 67 ms
71,248 KB
testcase_42 AC 67 ms
71,248 KB
testcase_43 AC 66 ms
73,292 KB
testcase_44 AC 66 ms
73,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    from itertools import combinations
    from random import shuffle
    input = sys.stdin.readline

    N = int(input())
    A = []
    PE = []
    P = {}
    for i in range(N):
        M = int(input())
        a = 1
        D = {}
        for j in range(M):
            p, e = map(int, input().split())
            if p not in P:
                P[p] = 0
            P[p] = max(P[p], e)
            a *= p ** e
            D[p] = e
        A.append(a)
        PE.append(D)

    B = []
    BA = []
    BB = []
    B_val = []
    for i in range(N):
        D = PE[i]
        b = set()
        val = 1
        for p in D:
            if D[p] == P[p]:
                b.add(p)
                val *= p
        if b:
            B.append(b)
            BA.append(A[i])
            B_val.append(val)
        else:
            BB.append(A[i])

    for i, b in enumerate(B):
        ok = 0
        for pp in P:
            if pp not in b:
                # ans[j].append(BA[i])
                ok = 1
                break
        if not ok:
            print(-1)
            exit()

    L = len(P)
    P_list = list(P.keys())
    shuffle(P_list)
    assert len(P_list) < 10
    for k in range(2, L+1):
        for J in combinations(P_list, k):
            J = list(J)
            q = 1
            for pp in J:
                q *= pp
            ans = [[] for _ in range(k)]
            flg = 1
            for i, b in enumerate(B_val):
                if b % q == 0:
                    flg = 0
                    break
            if flg:
                for i, b in enumerate(B):
                    for j, pp in enumerate(J):
                        if pp not in b:
                            ans[j].append(BA[i])
                            break
                ans[0].extend(BB)
                print(k)
                for a in ans:
                    a = [len(a)] + a
                    print(*a)
                exit()


if __name__ == '__main__':
    main()
0