You are viewing a single comment's thread. Return to all comments →
import sys def main(): N = int(sys.stdin.readline()) M = [] G = [] for i in range(3): M.append(int(sys.stdin.readline())) G.append([set() for _ in range(N)]) for _ in range(M[i]): u, v = map(int, sys.stdin.readline().split()) u, v = u - 1, v - 1 G[i][u].add(v) G[i][v].add(u) cpt = 0 for a in range(N): for b in G[0][a]: for c in G[1][b]: if a in G[2][c]: #print a,b,c cpt += 1 print(cpt) main()
Seems like cookies are disabled on this browser, please enable them to open this website
Tripartite Matching
You are viewing a single comment's thread. Return to all comments →