結果

問題 No.1711 Divide LCM
ユーザー tamatotamato
提出日時 2021-10-15 22:51:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,049 bytes
コンパイル時間 1,653 ms
コンパイル使用メモリ 81,776 KB
実行使用メモリ 153,632 KB
最終ジャッジ日時 2023-10-17 20:45:08
合計ジャッジ時間 12,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
56,216 KB
testcase_01 AC 43 ms
56,216 KB
testcase_02 AC 43 ms
56,152 KB
testcase_03 AC 69 ms
71,352 KB
testcase_04 AC 125 ms
78,548 KB
testcase_05 AC 312 ms
81,064 KB
testcase_06 AC 145 ms
78,488 KB
testcase_07 AC 259 ms
80,488 KB
testcase_08 AC 112 ms
78,652 KB
testcase_09 AC 232 ms
84,320 KB
testcase_10 AC 117 ms
78,668 KB
testcase_11 AC 206 ms
86,116 KB
testcase_12 AC 114 ms
78,740 KB
testcase_13 AC 59 ms
66,764 KB
testcase_14 AC 92 ms
77,660 KB
testcase_15 AC 99 ms
77,992 KB
testcase_16 AC 60 ms
68,816 KB
testcase_17 AC 92 ms
77,556 KB
testcase_18 AC 288 ms
119,220 KB
testcase_19 AC 290 ms
119,084 KB
testcase_20 AC 296 ms
119,044 KB
testcase_21 AC 330 ms
153,632 KB
testcase_22 AC 206 ms
95,420 KB
testcase_23 AC 210 ms
99,680 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = []
    for i in range(N):
        D = PE[i]
        b = set()
        for p in D:
            if D[p] == P[p]:
                b.add(p)
        if b:
            B.append(b)
            BA.append(A[i])
        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)
    for k in range(2, L+1):
        for J in combinations(P_list, k):
            J = list(J)
            ans = [[] for _ in range(k)]
            flg = 1
            for i, b in enumerate(B):
                ok = 0
                for j, pp in enumerate(J):
                    if pp not in b:
                        # ans[j].append(BA[i])
                        ok = 1
                        break
                if not ok:
                    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