結果
問題 | No.1711 Divide LCM |
ユーザー |
![]() |
提出日時 | 2021-10-15 22:51:18 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,049 bytes |
コンパイル時間 | 277 ms |
コンパイル使用メモリ | 82,588 KB |
実行使用メモリ | 154,160 KB |
最終ジャッジ日時 | 2024-09-17 17:56:35 |
合計ジャッジ時間 | 10,943 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 TLE * 1 -- * 20 |
ソースコード
mod = 998244353eps = 10**-9def main():import sysfrom itertools import combinationsfrom random import shuffleinput = sys.stdin.readlineN = int(input())A = []PE = []P = {}for i in range(N):M = int(input())a = 1D = {}for j in range(M):p, e = map(int, input().split())if p not in P:P[p] = 0P[p] = max(P[p], e)a *= p ** eD[p] = eA.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 = 0for pp in P:if pp not in b:# ans[j].append(BA[i])ok = 1breakif 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 = 1for i, b in enumerate(B):ok = 0for j, pp in enumerate(J):if pp not in b:# ans[j].append(BA[i])ok = 1breakif not ok:flg = 0breakif flg:for i, b in enumerate(B):for j, pp in enumerate(J):if pp not in b:ans[j].append(BA[i])breakans[0].extend(BB)print(k)for a in ans:a = [len(a)] + aprint(*a)exit()if __name__ == '__main__':main()