problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p02573
u411923565
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['\nimport sys\nsys.setrecursionlimit(10**6)\n\nN,M = map(int,input().split())\n\nlis = [[] for _ in range(N+1)]\nfor i in range(M):\n A,B = map(int,input().split())\n A,B = min(A,B),max(A,B)\n lis[A].append(B)\nprint(lis)\n \ncnt = 0\nseen = [False]*(N+1)\ndef dfs(v,graph):\n global cnt\n seen[v] = T...
['Wrong Answer', 'Accepted']
['s992700051', 's381924763']
[204184.0, 210608.0]
[801.0, 711.0]
[618, 599]
p02573
u414050834
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import Counter\nn,m=map(int,input().split())\nl=[]\nfor i in range(m):\n s=[]\n a,b=map(int,input().split())\n s.append(a)\n s.append(b)\n l.append(s)\ndef get_unique_list(seq):\n seen = []\n return [x for x in seq if (x or reversed(x)) not in seen and not seen.append(x)]\nls=get_unique_li...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s195921835', 's423412823', 's813687048', 's092146275']
[43032.0, 42960.0, 9020.0, 13240.0]
[2207.0, 2207.0, 25.0, 668.0]
[368, 371, 809, 807]
p02573
u417365712
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind():\n def __init__(self, n):\n self._n = n\n self._table = [-1]*n\n\n def _root(self, x):\n stack = []\n while self._table[x] >= 0:\n stack.append(x)\n x = self._table[x]\n for y in stack:\n self._table[y] = x\n return x\n...
['Runtime Error', 'Accepted']
['s606673727', 's780656197']
[57280.0, 57412.0]
[327.0, 453.0]
[1178, 1194]
p02573
u427427681
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N,M = tuple(map(int,input().split()))\n# matchlist = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]\n\n\ngplist = [[-1]]\ndef match(ab):\n a,b=ab\n igpa = 0\n igpb = 0\n for i,gp in enumerate(gplist):\n if a in gp:\n igpa = i\n if b in gp:\n r...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s315940826', 's795397412', 's932017523']
[9960.0, 162676.0, 50256.0]
[2206.0, 2345.0, 912.0]
[970, 564, 834]
p02573
u432621419
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['\n\nn,m = map(int,input().split())\n\na = [list(map(int,input().split())) for i in range(m)]\n\n#print(a[0][1])\n\nl = [n+1]*n\n\np = [1]*n\n\n\n\n\n\n\nfor j in range(m):\n if(l[a[j][0]] == n+1 & l[a[j][1]] == n+1):\n if(a[j][0] > a[j][1]):\n l[a[j][0]] = a[j][1]\n l[a[j][1]] = a[j][1...
['Runtime Error', 'Accepted']
['s604344579', 's557698661']
[9052.0, 14408.0]
[28.0, 731.0]
[893, 2664]
p02573
u446782476
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["NM = input()\nN = int(NM.split()[0])\nM = int(NM.split()[1])\ninfo = []\nfor i in range(M):\n info += [input()]\n\ninfo_friend = [info[i].split() for i in range(M)]\nprint(info)\nfriends = ['']*N\nfor j in range(N):\n friends[j] = str(j+1)\n for i in range(M):\n AB = info[i].split()\n A = AB[0]...
['Wrong Answer', 'Accepted']
['s678137795', 's029709295']
[88068.0, 28700.0]
[2211.0, 556.0]
[510, 1480]
p02573
u452512115
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N, M = map(int, input().split())\n\n\n\ngraph = [[i+1] for i in range(M)]\n\nfor _ in range(M):\n a, b = map(int, input().split())\n graph[a-1].append(b)\n graph[b-1].append(a)\n\nans = -1\nfor g in graph:\n ans = max(ans, len(set(g)))\nprint(ans)\n', 'N, M = map(int, input().split())\n\n\n\ngraph = [[i+1] for i ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s708619191', 's902390575', 's074596705']
[52564.0, 64456.0, 45580.0]
[773.0, 935.0, 981.0]
[336, 349, 974]
p02573
u457554982
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import sys\nsys.setrecursionlimit(99999999)\n\n\n[n,m]=list(map(int,input().split()))\nfriends=[]\nfor i in range(m):\n friends.append(list(map(int,input().split())))\n\ntomodachi=[[]for i in range(n)]\n\nfor i in range(m):\n tomodachi[friends[i][0]-1].append(friends[i][1]-1)\n tomodachi[friends[i][1]-1].app...
['Wrong Answer', 'Accepted']
['s406432851', 's824371303']
[263100.0, 263064.0]
[1185.0, 1316.0]
[974, 978]
p02573
u458967973
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\ndata2 = []\nfor i in range(m):\n data2.append(input().split())\n\n\ngraph = [[] for i in range(n)]\nfor i in range(m):\n a, b = map(lambda z: int(z) - 1, data2[m])\n graph[a].append(b)\n graph[b].append(a)\n\nprint(graph)\nsize = [0 for i in range(n)]\ncheck = [True for i...
['Runtime Error', 'Accepted']
['s700301702', 's497548558']
[150528.0, 110432.0]
[2373.0, 1074.0]
[694, 658]
p02573
u470560351
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["N, M=map(int, input().split())\nimport collections\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s064886842', 's768132211', 's863922291']
[17612.0, 17856.0, 14528.0]
[626.0, 657.0, 582.0]
[1447, 1471, 1389]
p02573
u490489966
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['# D\nfrom collections import Counter\nn, m = map(int, input().split())\nab = [list(map(int, input().split()))for _ in range(m)]\nab.sort(key=lambda x:x[1])\nab.sort(key=lambda x:x[0])\n# print(ab)\npeople=[0]*n\nfor i in ab:\n if people[i[0]-1]==0:\n people[i[0]-1]=i[0]\n if people[i[1]-1]==0:\n p...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s117079495', 's843675974', 's913825775', 's996961195']
[73468.0, 56964.0, 57028.0, 18480.0]
[853.0, 1008.0, 1035.0, 605.0]
[407, 482, 462, 2300]
p02573
u513434790
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import sys\nsys.setrecursionlimit(10*100)\n\nN, M = map(int, input().split())\nUF = [-1] * (N+1)\ndef find(x):\n global UF\n if UF[x] == -1:\n return x\n else:\n UF[x] = find(UF[x])\n return UF[x]\ndef union(x,y):\n global UF\n xx = find(x)\n yy = find(y)\n if UF[x] == UF[y] ...
['Wrong Answer', 'Accepted']
['s847218776', 's611913428']
[14816.0, 36784.0]
[595.0, 694.0]
[603, 597]
p02573
u521271655
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import Counter\nn,m = map(int,input().split())\ngroup = {}\nfor i in range(1,n+1):\n group[i] = i\nfor _ in range(m):\n a,b = map(int,input().split())\n k = min(group[a],group[b])\n group[a] = k\n group[b] = k\np = Counter(group.values())\nprint(max(p.values()) + 1)\n', 'from collectio...
['Wrong Answer', 'Accepted']
['s921799573', 's192020581']
[46044.0, 14884.0]
[568.0, 693.0]
[288, 787]
p02573
u521866787
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind:\n def __init__(self, n):\n self.par = list(range(n)) \n self.rank = [0] * n \n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def unite(sel...
['Runtime Error', 'Accepted']
['s951173297', 's453321576']
[18312.0, 14504.0]
[721.0, 766.0]
[1147, 1967]
p02573
u522293645
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import collections \n# import itertools # accumulate, compress, permutations(nPr), combinations(nCr)\n\n\n# import heapq\n\n# from fractions import Fraction\n# from math import gcd # <Python3.5\n# --------------------------------------------------------------\n\nclass UnionFind():\n def __init__(self, n):\n ...
['Runtime Error', 'Accepted']
['s638093355', 's147106947']
[47656.0, 68012.0]
[591.0, 1275.0]
[1860, 2029]
p02573
u531599639
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import deque\nn,m = map(int,input().split())\nl = [set([]) for i in range(n+1)]\nfor i in range(m):\n a,b = map(int,input().split())\n l[a].add(b)\n l[b].add(a)\nQ = deque()\nfor i in range(n):\n Q.append(i+1)\nvis = [-1]*(n+1)\nvis[1] = 1\nwhile Q:\n temp = Q.popleft()\n for v in l[temp]:\n ...
['Wrong Answer', 'Accepted']
['s477958872', 's524312913']
[80204.0, 16112.0]
[2209.0, 710.0]
[399, 1340]
p02573
u540627185
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import sys\nsys.setrecursionlimit(10**7)\ndef input(): return sys.stdin.readline().rstrip()\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x...
['Runtime Error', 'Accepted']
['s601036891', 's152242557']
[9060.0, 19956.0]
[26.0, 381.0]
[1445, 1439]
p02573
u543016260
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import sys\nimport math\nN=int(input())\nA=list(map(int,input().split()))\n\n\ndef sieve_of_eratosthenes(n): \n candidate = list(range(2, n+1)) \n prime = []\n limit = n**0.5 + 1 \n\n while True:\n p = candidate[0] \n if limit <= p:\n prime.extend(candidate) \n break\n ...
['Runtime Error', 'Accepted']
['s273461688', 's532545408']
[9092.0, 46220.0]
[24.0, 733.0]
[1250, 915]
p02573
u544587633
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['#!/usr/bin/env python3\nimport sys\nimport networkx as nx\nfrom random import randint\ndef solve(N: int, M: int, A: "List[int]", B: "List[int]"):\n G=nx.Graph()\n\n if M == 0 :\n print(1)\n return\n\n for a, b in zip(A,B):\n G.add_edge(a, b)\n\n Gc = max(nx.connected_components(G), ke...
['Time Limit Exceeded', 'Accepted']
['s937897216', 's650085983']
[53544.0, 258428.0]
[2208.0, 1751.0]
[975, 963]
p02573
u572271833
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["#Union Find\n\n\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x == y:\n return False\n else:\n \n if par[x] > par[y]:\n x,y = y,x\n par[x]...
['Runtime Error', 'Accepted']
['s291581001', 's919203040']
[32384.0, 32444.0]
[593.0, 648.0]
[807, 811]
p02573
u576335153
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\nab = [list(map(int, input().split()))]\n\nfriends = [0]*n\ngroup = [-1]*n\n\nfor a, b in ab:\n if a > b:\n a, b = b, a\n a -= 1\n b -= 1\n if group[a] == -1 and group[b] == -1:\n group[a] = a\n group[b] = b\n friends[a] += 2\n elif group[a] ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s581672160', 's804048831', 's295013484']
[11936.0, 11656.0, 15796.0]
[38.0, 143.0, 860.0]
[593, 1728, 1729]
p02573
u581022379
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import Counter\nN, M = map(int, input().split())\ngroups = [0] * (N + 1)\ngroup_num_list = [[0]]\ngroup_num = 1\nfor _ in range(M):\n A, B = map(int, input().split())\n if groups[A] != 0 and groups[B] != 0:\n if groups[A] != groups[B]:\n lower = min(groups[A], groups[B])\n ...
['Runtime Error', 'Accepted']
['s730237974', 's983318990']
[10908.0, 31380.0]
[43.0, 727.0]
[1079, 1147]
p02573
u581403769
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\n\npar = [i + 1 for i in range(n)]\nrank = [0] * n\nsize = [1] * n\n\ndef find(x):\n if par[x - 1] == x:\n return x\n else:\n return find(par[x - 1])\n\ndef union(x, y):\n x = find(x)\n y = find(y)\n if rank[x] < rank[y]:\n par[x] = y\n size[...
['Runtime Error', 'Accepted']
['s134951086', 's548524353']
[63560.0, 20136.0]
[619.0, 691.0]
[517, 591]
p02573
u583285098
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import collections\n\nn, m = map(int, input().split())\nif m == 0:\n print(1)\n exit()\nif m == 1:\n print(2)\n exit()\nids = {i: 0 for i in range(1, n+1)}\nid = 1\nfor _ in range(m):\n a, b = map(int, input().split())\n if ids[a] == 0 and ids[b] != 0:\n ids[a] = ids[b]\n elif ids[a] != 0 ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s025451698', 's307342392', 's338344245', 's501133574']
[32476.0, 18596.0, 18740.0, 18760.0]
[564.0, 1989.0, 2206.0, 1857.0]
[514, 594, 570, 525]
p02573
u585963734
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import collections as col\nfrom collections import defaultdict as dd\n\nd=dd(list)\n\nN,M=map(int, input().split())\np=[-1]*N\ncnt=[0]*N\n\nfor _ in range(M):\n i,j=map(int, input().split())\n if i>j:\n i,j=j,i\n d[i].append(j)\n\nfor i in d:\n for j in d[i]:\n print(i,j)\n if p[j-1]!...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s018416900', 's056183100', 's088353080', 's240530425', 's787641035', 's807840027', 's366987523']
[55496.0, 240688.0, 63984.0, 240544.0, 83100.0, 41408.0, 22140.0]
[727.0, 2212.0, 1202.0, 2211.0, 2208.0, 2206.0, 598.0]
[581, 1069, 894, 1056, 772, 519, 662]
p02573
u594803920
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 8)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisec...
['Wrong Answer', 'Accepted']
['s818480816', 's009997368']
[2689616.0, 223100.0]
[2344.0, 594.0]
[1470, 1312]
p02573
u604522449
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import sys,os\nimport math\nfrom fractions import Fraction \nfrom collections import defaultdict\nfrom random import randint\n\n# sys.stderr=open('err.txt','w')\n# sys.stdout=open('output.txt','w')\n# sys.stdin=open('input.txt','r')\n\ndef linput():\n return list(minput())\n\ndef minput():\n return map(int, sys...
['Runtime Error', 'Accepted']
['s329706787', 's834306286']
[33672.0, 19728.0]
[164.0, 473.0]
[1003, 1127]
p02573
u610042046
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\nfr = [set() for x in range(n+1)]\nfor _ in range(m):\n a, b = map(int, input().split())\n fr[a].add(b)\n fr[b].add(a)\nprint(fr)\nmax_fr = 0\nfor i in fr:\n max_fr = max(len(i)+1, max_fr)\nprint(max_fr)', 'n, m = map(int, input().split())\nfr = [[] for _ in range(n)]\nfor...
['Wrong Answer', 'Accepted']
['s282737312', 's495418404']
[77444.0, 44484.0]
[979.0, 810.0]
[238, 665]
p02573
u618251217
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from sys import stdin\ninput = stdin.readline\n\nN,M = map(int, input().split())\nlis = [0]*(N+1)\nA = [0]*M; B = [0]*M\nfor i in range(M):\n a, b = map(int, input().split())\n a,b = min(a,b), max(a,b)\n if lis[a] == 0:\n lis[a] = a\n else:\n lis[b] = lis[a]\n\nlis.sort()\nmaxcnt = 0\ncnt = ...
['Wrong Answer', 'Accepted']
['s266735195', 's787396951']
[19696.0, 49432.0]
[411.0, 590.0]
[547, 751]
p02573
u619850971
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind(): \n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n\n x = self.find(...
['Runtime Error', 'Accepted']
['s867463274', 's837967562']
[8928.0, 14516.0]
[29.0, 759.0]
[911, 937]
p02573
u623283955
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n,m=map(int,input().split())\np=[(i,1)for i in range(n)]\ndef find(i):\n if p[i][0]==i:return i\n else:\n c=find(p[i][0])\n p[i]=(c,0)\n return c\ndef union(i,j):\n pi=find(i)\n pj=find(j)\n if not pi==pj:\n if p[pi][1]>p[pj][1]:\n p[pi]=(pi,p[pi][1]+p[pj][1])\n p[pj]=(pi,0)\n else:\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s296801397', 's334849136', 's700342851']
[29640.0, 29628.0, 29624.0]
[639.0, 538.0, 969.0]
[496, 452, 500]
p02573
u627600101
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["from math import gcd\n\n# = map(int, input().split())\nN = int(input())\nA = list(map(int, input().split()))\nmA = max(A)\ncounter = [0 for _ in range(mA+1)]\n\nprimenum = [2]\nsgn = [-1 for _ in range(int(mA**0.5)+1)]\nk = 3\nwhile k**2 <= mA:\n if sgn[k] == -1:\n primenum.append(k)\n add = k*k\n ok = k\n ...
['Runtime Error', 'Accepted']
['s267844419', 's890205191']
[9156.0, 212224.0]
[27.0, 873.0]
[975, 617]
p02573
u630554891
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n,m= map(int, input().split())\npar = [i for i in range(n)]\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x > y:\n par[x] = y\n find(x)\n else:\n par[y] = x\n find(y)\n\nif m > 0: \n for ...
['Wrong Answer', 'Accepted']
['s077712083', 's463058719']
[19672.0, 18384.0]
[2206.0, 683.0]
[515, 543]
p02573
u638902622
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import sys\n\ndef IS(): return sys.stdin.readline().rstrip()\ndef II(): return int(IS())\ndef MII(): return list(map(int, IS().split()))\ndef MIIZ(): return list(map(lambda x: x-1, MII()))\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n def find(self, x):\n ...
['Wrong Answer', 'Accepted']
['s611482931', 's004526767']
[47324.0, 49532.0]
[534.0, 609.0]
[1637, 1667]
p02573
u649769812
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\n\nfriend_list = [set()]\ninput_list = []\n\nfor i in range(m):\n a, b = map(int, input().split())\n input_list.append([sorted([a, b])])\n\nsorted(input_list)\n\nfor inp in input_list:\n found = False\n for friend_set in friend_list:\n if inp[0] in friend_set:\n ...
['Runtime Error', 'Accepted']
['s187618790', 's922593161']
[63580.0, 35884.0]
[1019.0, 829.0]
[706, 801]
p02573
u649840780
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class Node():\n def __init__(self,index):\n self.index = index\n self.parent = self \n self.size = 1\n\n @staticmethod\n def find_set(node):\n return node\n if node.parent == node:\n return node \n root = Node.find_set(node.parent)\n node.parent = r...
['Wrong Answer', 'Accepted']
['s401170925', 's382871358']
[50428.0, 50432.0]
[957.0, 1092.0]
[1212, 1255]
p02573
u667084803
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N, M = map(int, input().split())\npath = [set() for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n path[a-1].add(b-1)\n path[b-1].add(a-1)\nvisited = [0] * N\n\nans = 1\nfor u in range(N):\n if visited[u] == 1:\n continue\n curr = 1\n next_u = path[u]\n while next_...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s118700669', 's351256715', 's508024818']
[77552.0, 158472.0, 77724.0]
[917.0, 2209.0, 886.0]
[546, 572, 565]
p02573
u671455949
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n, m = map(int, input().split())\ngroup_idx = [i for i in range(n)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n if a > b:\n a, b = b, a\n group_idx[b - 1] = group_idx[a - 1]\n print(group_idx)\n\ngroups = [0 for i in range(n)]\n\nfor i in range(n):\n groups[group_idx[i]] += 1\n\nprint(group_idx...
['Runtime Error', 'Accepted']
['s370472496', 's832455988']
[149524.0, 14288.0]
[3774.0, 692.0]
[323, 793]
p02573
u686036872
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind:\n def __init__(self, N):\n self.N = N\n self.parent = [-1] * N\n\n def root(self, A):\n if (self.parent[A] < 0):\n return A\n self.parent[A] = self.root(self.parent[A])\n return self.parent[A]\n\n def size(self, A):\n return -self.parent[s...
['Runtime Error', 'Accepted']
['s305963280', 's209573870']
[10556.0, 14784.0]
[34.0, 909.0]
[854, 880]
p02573
u686230543
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['def zero_origin(s: str):\n return int(s) - 1\n\n\nclass UnionFindTree:\n """Union Find Tree for disjoint-set data structure.\n\n Args:\n n (int): number of the vertices.\n """\n def __init__(self, n: int):\n self.parent = list(range(n))\n self.rank = [0] * n\n self.size = [1] * n\n\n def find(self, ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s198593637', 's251128056', 's953118159']
[105000.0, 104980.0, 20080.0]
[1073.0, 1069.0, 726.0]
[1036, 1036, 1023]
p02573
u698902360
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import sys\nfrom collections import defaultdict\nimport collections\n\n\nclass UnionFind2:\n def __init__(self, size):\n \n \n self.table = [-1 for _ in range(size)]\n\n \n def find(self, x):\n if self.table[x] < 0:\n return x\n else:\n \n s...
['Runtime Error', 'Accepted']
['s263687645', 's521067431']
[44568.0, 51028.0]
[781.0, 925.0]
[946, 807]
p02573
u719260857
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import collections\n\nn, m = map(int, input().split(' '))\n\nf = [x for x in range(n)]\n\ndef find(x):\n if f[x] == x:\n return x\n root = find(f[x])\n f[x] = root\n return root\n\nfor i in range(m):\n a, b = map(int, input().split(' '))\n a -= 1\n b -= 1\n if find(a) != find(b):\n f[find(a)] = find(b)\...
['Runtime Error', 'Accepted']
['s242481920', 's844527971']
[32228.0, 174528.0]
[765.0, 751.0]
[385, 435]
p02573
u732061897
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import deque\n\nn, m = list(map(int, input().split()))\nedges = [list(map(int, input().split())) for _ in range(m)]\n\nneighbor = [[] for _ in range(n)]\nfor edge in edges:\n neighbor[edge[0] - 1].append(edge[1] - 1) \n neighbor[edge[1] - 1].append(edge[0] - 1)\n\nprint(neighbor)\nvisited = [-...
['Wrong Answer', 'Accepted']
['s450797333', 's780360434']
[85756.0, 36000.0]
[1012.0, 718.0]
[803, 556]
p02573
u740284863
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import *\nn,m = map(int,input().split())\npar = [-1 for _ in range(n)]\n\ndef root(i):\n if par[i] < 0:\n return i\n else:\n return root(par[i])\n\ndef size(a):\n return -par[root(a)]\n\ndef union(a,b):\n a = root(a)\n b = root(b)\n if a == b:\n return False\n ...
['Runtime Error', 'Accepted']
['s114842605', 's806654260']
[22000.0, 22640.0]
[749.0, 765.0]
[763, 724]
p02573
u748311048
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y)...
['Wrong Answer', 'Accepted']
['s579086587', 's010868711']
[14400.0, 14476.0]
[576.0, 742.0]
[1275, 1333]
p02573
u760961723
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\nfrom collections import defaultdict\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nMOD2 = 998244353\nINF = float('inf')\n#input = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(in...
['Runtime Error', 'Accepted']
['s479698028', 's579533217']
[254696.0, 14888.0]
[769.0, 568.0]
[1572, 1801]
p02573
u763550415
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['def uf_find(x):\n z = x\n while z != p[z]:\n z = p[z]\n p[x] = z\n return z\n\ndef uf_unite(x,y):\n global rand\n x = uf_find(x)\n y = uf_find(y)\n if x != y:\n rand += 1\n if rand % 2 ==0:\n p[y] = x\n else:\n p[x] = y\n\nN, M = map(int, input().split())\np = list(range(N))\nrand = 0\n\...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s438602924', 's631857125', 's740644796', 's781741503', 's957260762', 's478069442']
[148516.0, 150064.0, 52768.0, 19680.0, 8992.0, 20024.0]
[2357.0, 2372.0, 2267.0, 2206.0, 28.0, 648.0]
[506, 562, 432, 505, 448, 440]
p02573
u794448346
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N,M = map(int,input().split())\nf = []\nfor i in range(M):\n A,B = map(int,input().split())\n a = {A,B}\n for i in f:\n if i & a != set():\n a = i | a\n f.remove(i)\n# print(f,a,i)\n f.append(a)\n\n#print(f)\nprint(len(max(f)))', 'N,M = map(int,input().split())\nf =...
['Runtime Error', 'Accepted']
['s582018629', 's391869220']
[17652.0, 57376.0]
[2206.0, 781.0]
[266, 516]
p02573
u803865203
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import Counter\n\nclass UnionFind:\n def __init__(self,num:int):\n self.r = [-1 for i in range(num)]\n def root(self,x:int):\n if(self.r[x] < 0):\n return x\n self.r[x] = self.root(self.r[x])\n return self.r[x]\n def unite(self,x:int,y:int):\n rx...
['Wrong Answer', 'Accepted']
['s652213429', 's221903636']
[17868.0, 15124.0]
[785.0, 758.0]
[817, 802]
p02573
u814986259
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import collections\n\n\nclass unionFind:\n parent = []\n\n def __init__(self, N):\n self.parent = [i for i in range(N)]\n\n def root(self, x):\n if self.parent[x] == x:\n return(x)\n else:\n self.parent[x] = self.root(self.parent[x])\n return(self.parent[...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s123008981', 's296751625', 's934501686', 's844764610']
[43076.0, 17276.0, 17936.0, 201860.0]
[855.0, 704.0, 842.0, 861.0]
[844, 850, 845, 892]
p02573
u818213347
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n,m = map(int,input().split())\nbranch = set(tuple(map(int,input().split())) for i in range(m))\nprint(branch)\nque = range(n)\nflag = -1\nfriend = [{0}]\n\nfor a,b in branch:\n for i in range(len(friend)):\n if (a in friend[i]) or (b in friend[i]):\n friend[i].add(a)\n friend[i].add(b...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s129495785', 's245785264', 's754837337', 's767443318', 's386135089']
[174144.0, 50788.0, 59748.0, 9092.0, 266172.0]
[2370.0, 2210.0, 2058.0, 26.0, 1113.0]
[613, 595, 574, 856, 874]
p02573
u850390157
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import defaultdict\n\nN, M = map(int, input().split())\nfriend = defaultdict(set)\nleader = []\nfor i in range(M):\n Ai, Bi = map(int, input().split())\n friend[Ai].add(Bi)\n friend[Bi].add(Ai)\nprint(friend)\nalready = {}\nanswer = 0\nfor i in range(1, N + 1):\n if i in already:\n ...
['Wrong Answer', 'Accepted']
['s652360776', 's766182206']
[100424.0, 100492.0]
[1146.0, 1018.0]
[788, 774]
p02573
u866949333
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["from collections import defaultdict\nfrom collections import deque\n\n\ndef main():\n N, M = map(int, input().split())\n A = [0] * M\n B = [0] * M\n\n for i in range(M):\n a, b = map(int, input().split())\n A[i] = a - 1\n B[i] = b - 1\n\n friends = defaultdict(set)\n\n for i in ...
['Wrong Answer', 'Accepted']
['s803378113', 's359596510']
[95880.0, 95868.0]
[1011.0, 901.0]
[1187, 1189]
p02573
u868055170
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.pare...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s007482431', 's488278900', 's528146112', 's850262727', 's974066977']
[9048.0, 9064.0, 8928.0, 8944.0, 14348.0]
[27.0, 25.0, 27.0, 26.0, 756.0]
[615, 624, 610, 619, 816]
p02573
u872538555
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from collections import Counter\n\nclass UnionFind():\n def __init__(self, n):\n self.par = [i for i in range(n + 1)]\n self.rank = [0] * n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n ...
['Runtime Error', 'Accepted']
['s217486753', 's739735306']
[36248.0, 33736.0]
[858.0, 820.0]
[1018, 843]
p02573
u875769753
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N,M = map(int,input().split())\nlsa = [{i} for i in range(N+1)]\nfor i in range(M):\n a,b = map(int,input().split())\n lsa[a] = lsa[a] | lsa[b]\n lsa[b] = lsa[a] | lsa[b]\nans = 0\nfor i in range(N+1):\n ans = max(ans,len(lsa[i]))\nprint(lsa)\nprint(ans)', 'from collections import deque\n\nn, m = map(int,...
['Wrong Answer', 'Accepted']
['s569114137', 's540254947']
[2865416.0, 45004.0]
[2295.0, 712.0]
[256, 600]
p02573
u894521144
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["from collections import Counter\n\ndef main(N, M, C):\n lst = [n for n in range(N)]\n\n def get_root(x):\n if lst[x] == x:\n return x\n else:\n lst[x] = get_root(lst[x])\n return lst[x]\n\n def is_same(x, y):\n return get_root(x) == get_root(y)\n\n def...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s211745499', 's772519999', 's592918919']
[59528.0, 9412.0, 52524.0]
[762.0, 32.0, 855.0]
[709, 1401, 1464]
p02573
u896726004
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
["class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n \n \n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n \n d...
['Runtime Error', 'Accepted']
['s370034908', 's991983290']
[14564.0, 14588.0]
[589.0, 749.0]
[1635, 1859]
p02573
u906501980
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from numba import njit\n\n\nclass UnionFind:\n __slots__ = ["data"]\n \n def __init__(self, n=0):\n self.data = [-1]*(n+1)\n \n def root(self, x):\n if self.data[x] < 0:\n return x\n self.data[x] = self.root(self.data[x])\n return self.data[x]\n \n def unite...
['Runtime Error', 'Accepted']
['s345067006', 's373059729']
[106508.0, 13612.0]
[476.0, 709.0]
[1043, 1038]
p02573
u909224749
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFindTree():\n def __init__(self, num_leaves):\n #self.num_leaves = num_leaves\n self.root = [i for i in range(num_leaves+1)]\n \n def find(self, leaf):\n if self.root[leaf] == leaf:\n return self.root[leaf]\n else:\n self.root[leaf] = self.find...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s360861592', 's558774999', 's938141707', 's193454352']
[18412.0, 29228.0, 17068.0, 14352.0]
[2206.0, 661.0, 2206.0, 588.0]
[844, 850, 872, 921]
p02573
u938005055
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind:\n def __init__(self, length):\n self.r = [-1] * length\n\n def root(self, x):\n if (self.r[x]) < 0:\n return x\n\n return self.r[x] - self.root(self.r[x])\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n\n if x == y:\n ...
['Runtime Error', 'Accepted']
['s322977872', 's543695459']
[14516.0, 14308.0]
[500.0, 707.0]
[744, 786]
p02573
u941438707
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['(n,m),*e=[[*map(int,i.split())]for i in open(0)]\nd=[[]for i in range(n+1)]\ndd=[[]for i in range(n+1)]\nfor i,j in e:\n d[i]+=[j]\n d[j]+=[i]\nfor i in range(n+1):\n for j in set(d[i]):\n dd[i]+=d[j]\nprint(max(len(set(dd[i]))for i in range(n+1)))', 'def find(x):\n if par[x]==x:\n return x\...
['Wrong Answer', 'Accepted']
['s717378149', 's541165210']
[2353160.0, 18504.0]
[2279.0, 615.0]
[255, 434]
p02573
u962330718
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N,M=map(int,input().split())\n\nP=[[0,0,0]]\nfor i in range(1,N+1):\n P.append([i,i,1])\n\nR=[]\nfor i in range(M):\n a,b=map(int,input().split())\n c=max(a,b)\n a=min(a,b)\n b=c\n R.append((a,b))\n\nR=sorted(list(set(R)))\n\nfor i in range(len(R)):\n \n x=0\n \n y=0\n \n cnt=0\n ...
['Wrong Answer', 'Accepted']
['s325302598', 's986212759']
[75864.0, 14832.0]
[1505.0, 679.0]
[1031, 810]
p02573
u964904181
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['from copy import deepcopy\n\nn, m = map(int, input().split())\n\npairs = [0] * m\nfor i in range(m):\n pairs[i] = list(map(int, input().split()))\n\n\n# N = 5\n\n\nprint(pairs)\n\nclass UnionFind:\n def __init__(self, N):\n self.r = [-1] * N\n\n def root(self, x):\n if self.r[x] < 0:\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s361596743', 's405062382', 's967867970', 's281154629']
[52168.0, 52116.0, 9272.0, 50156.0]
[524.0, 939.0, 34.0, 855.0]
[891, 891, 896, 878]
p02573
u968404618
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['# Union find\n\n# https://www.youtube.com/watch?time_continue=916&v=zxor0DdwoXA&feature=emb_logo\n# https://www.slideshare.net/chokudai/union-find-49066733\n\nimport sys\nsys.setrecursionlimit(10 ** 9)\n\nn, m = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(m)]\n\nroot = [-1]*n\n\nde...
['Runtime Error', 'Accepted']
['s884987492', 's947232689']
[184292.0, 49884.0]
[2385.0, 631.0]
[864, 493]
p02573
u970082363
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['n,m = (int(x) for x in input().split())\nfriendlist = [0]*n\nclasses = 1\nfor i in range(m):\n a,b = (int(x)-1 for x in input().split())\n if friendlist[a]!=0:\n friendlist[b] = friendlist[a]\n elif friendlist[b]!=0:\n friendlist[a] = friendlist[b]\n else:\n friendlist[a] = classes\n ...
['Runtime Error', 'Accepted']
['s688425875', 's774184503']
[12608.0, 14756.0]
[507.0, 685.0]
[465, 852]
p02573
u970267139
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind():\n def __init__(self, n):\n self.par = [-1]*n\n\n def root(self, x):\n if self.par[x] < 0:\n return x\n return self.root(self.par[x])\n\n def unite(self, x, y):\n if x > y:\n x, y = y, x\n rx = self.root(x)\n ry = self.root(y)\...
['Runtime Error', 'Accepted']
['s514857902', 's657554269']
[10600.0, 59084.0]
[28.0, 841.0]
[808, 890]
p02573
u970348538
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['def search(x, num):\n return num + 1\n\n(n,m),*d = [list(map(int, s.split())) for s in open(0)]\n\nedge = [set() for _ in range(n+1)]\nfor x in d:\n edge[x[0]].add(x[1])\n edge[x[1]].add(x[0])\n\nnodes = set(range(1,n+1))\nans = 1\nfor x in list(nodes):\n if x in nodes:\n nodes.remove(x)\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s448131290', 's455522902', 's537152570', 's680268715', 's741837798', 's284657698']
[111660.0, 111844.0, 111920.0, 94512.0, 111932.0, 291436.0]
[982.0, 846.0, 854.0, 733.0, 884.0, 1043.0]
[360, 504, 481, 337, 477, 516]
p02573
u977422582
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['N,M=map(int,input().split())\npar=[i for i in range(N+1)]\nsize=[1 for i in range(N+1)]\ndef find(x):\n if x!=par[x]:\n par[x]=find(par[x])\n return par[x]\ndef union(x,y):\n if find(x)!=find(y):\n par[y] = par[x]\n size[x] += size[y]\nres=N\nfor i in range(M):\n s,e=map(int,input().s...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s671892228', 's736640259', 's449380117']
[18528.0, 18496.0, 18484.0]
[627.0, 704.0, 655.0]
[434, 421, 374]
p02573
u991542950
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['class UnionFind:\n def __init__(self, n):\n self.parent = [-1] * n\n self.rank = [-1] * n\n self.count = [-1] * n\n\n def get_root(self, i):\n while self.parent[i] != -1:\n i = self.parent[i]\n return i\n\n def is_same_tree(self, i, j):\n return self.get_root(i) == self.get_root(j)\n\n def ...
['Wrong Answer', 'Accepted']
['s772203563', 's966843490']
[16620.0, 16356.0]
[664.0, 671.0]
[843, 841]
p02573
u994935583
2,000
1,048,576
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
['import numpy as np\nN, M = map(int, input().split())\nA = np.zeros((M,2), dtype=int)\n\nfor i in range(M):\n Ai = input().split()\n A[i,0] = int(Ai[0])\n A[i,1] = int(Ai[1])\n\nAsort = np.sort(A, axis=0)\n\nGrp_lst = np.arange(1, N+1)\nfor i in range(M):\n Grp_lst[Asort[i,1] - 1] = Grp_lst[Asort[i,0] - 1]...
['Wrong Answer', 'Accepted']
['s478866628', 's122399741']
[36064.0, 16776.0]
[889.0, 361.0]
[404, 797]
p02574
u023229441
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from subprocess import*\ncall(('pypy3','-c',))", 'import sys\nmod=10**9+7 ; inf=float("inf")\nfrom math import sqrt, ceil\nfrom collections import deque, Counter, defaultdict \ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom decimal import ROUND_HALF_UP,Decimal \n \nfrom functools ...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s231339837', 's284451072', 's339042157']
[261420.0, 133608.0, 150516.0]
[2206.0, 2210.0, 923.0]
[2216, 2120, 296]
p02574
u062691227
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['import numpy as np\nN=int(input())\nA=list(map(int,input().split()))\n# cnt=[0]*(10**6+1)\ncnt=np.zeros(10**6+1, dtype=\'int\')\nfor a in A:cnt[a]+=1\n \nif np.gcd.reduce(A)!=1:\n print("not coprime")\nelif np.all([sum(cnt[i::i])<=1 for i in range(2,10**6+1)]):\n print("pairwise coprime")\nelse:\n print("setwise c...
['Time Limit Exceeded', 'Accepted']
['s717352861', 's237241983']
[150596.0, 150436.0]
[2208.0, 1016.0]
[312, 361]
p02574
u133936772
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["M=10**6+1\nf=lambda p: exit(print(['pairwise','setwise','not'][p]+' coprime'))\nn,*l=map(int,open(0).read().split())\nfrom math import *\ng=l[0]\nfor x in l: g=gcd(g,x)\nif g>1: f(2)\nC=[0]*M\nfor x in l: C[x]=1\nfor i in range(2,M):\n if sum(C[j] for j in range(i,M,i))>1: f(1)\nf(0)", "M=10**6+1\nf=lambda p: exit(p...
['Time Limit Exceeded', 'Accepted']
['s496715927', 's243927491']
[126028.0, 127160.0]
[2051.0, 625.0]
[274, 443]
p02574
u157232135
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['import math\ndef main():\n n=int(input())\n a=list(map(int,input().split()))\n ap=[set(prime_factorize(i)) for i in a]\n x=set()\n for i in ap:\n if len(x & i) > 0:\n break\n x |= i\n else:\n print("pairwise coprime")\n return\n x=a[0]\n for i in a:\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s245735257', 's490212802', 's984219360', 's438182123']
[132736.0, 127668.0, 126944.0, 128008.0]
[241.0, 236.0, 240.0, 713.0]
[452, 1832, 870, 1844]
p02574
u222668979
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd\n\nn = int(input())\na = list(map(int, input().split()))\n\n\nans = 0\ncnt = [0] * (max(a) + 1)\nfor ai in a:\n ans = gcd(ans, ai)\n cnt[ai] += 1\n\nif ans != 1:\n print('not coprime')\nelif any(sum(cnt[i::i]) > 1 for i in range(max(a) + 1)):\n print('setwise coprime')\nelse:\n pri...
['Runtime Error', 'Accepted']
['s213124389', 's746963259']
[132732.0, 132708.0]
[501.0, 568.0]
[342, 345]
p02574
u223904637
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd\nn=int(input())\nl=list(map(int,input().split()))\nmal=max(l)\ne=[i for i in range(mal+1)]\n\nx=2\nwhile x*x <= mal:\n if x == e[x]:\n for m in range(x, len(e), n):\n if e[m] == m:\n e[m] = x\n x+=1\n#print(e) \ns=set()\nf=1\nfor i in l:\n st = set()\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s061240923', 's379369892', 's078340897']
[148032.0, 216316.0, 134580.0]
[1230.0, 2211.0, 768.0]
[563, 867, 564]
p02574
u229950162
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['max_num = 10**6 + 1\nprime = [i for i in range(max_num)]\nr2_num = int(max_num**(1/2))+1\nfor i in range(2, r2_num):\n if prime[i] == i:\n for j in range(i**2, max_num, i):\n if prime[j] == j:\n prime[j] = i\ndef gcd(a, b): # a >= b\n if a%b == 0:\n return b\n else:\n return gcd(b, a%b)\n\nflg...
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s607057872', 's876176681', 's604971046']
[144144.0, 137008.0, 137064.0]
[2209.0, 2208.0, 1122.0]
[1092, 986, 989]
p02574
u240630407
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['# import itertools\nimport math\nimport functools import reduce\n# import sys\n\n# import numpy as np\n# import heapq\n# from collections import deque\n\nN = int(input())\n# S = input()\n# n, *a = map(int, open(0))\n# N, M = map(int, input().split())\nA = list(map(int, input().split()))\n# B = list(map(int, input().s...
['Runtime Error', 'Accepted']
['s572191308', 's564017043']
[8928.0, 127636.0]
[25.0, 757.0]
[1845, 1854]
p02574
u249218427
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["N = int(input())\nM = 10**6 + 1\n\ncounts = [0 for _ in range(M)]\nfor a in map(int, input().split()):\n counts[a] += 1\n\nmax_count = 0\nfor i in range(2,M):\n count = 0\n for j in range(i,M,i):\n count += counts[j]\n max_count = max(max_count,count)\n\nif max_count == N:\n answer = 'not coprime'\nelif max_c...
['Time Limit Exceeded', 'Accepted']
['s215358265', 's938576948']
[101716.0, 101940.0]
[2207.0, 1058.0]
[392, 344]
p02574
u262869085
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['def divplis(N):\n lis = [i for i in range(N+1)]\n for i in range(int(N**0.5+1),1,-1):\n if lis[i] == i:\n lis[i::i] = [i]*(N//i)\n return lis\n\ndivp = divplis(10**6+1)\nprint(divp[:10])\nprint(divp[-10:])\nprint(len(divp)-1)\nprint((len(divp)-1)/divp[-1])\nN = int(input())\nd = [0]*(10**6+...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s112439650', 's141443925', 's591017225']
[151260.0, 151536.0, 151316.0]
[1686.0, 1772.0, 1710.0]
[652, 567, 568]
p02574
u317423698
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["import sys\nimport math\nimport functools\n\n\ndef resolve(in_):\n N = int(next(in_))\n A = tuple(map(int, next(in_).split()))\n\n max_a = max(A)\n temp = [0] * (max_a + 1)\n temp[1] = 1\n\n for i in range(2, max_a + 1):\n if temp[i]:\n continue\n\n j = i\n while j < ...
['Wrong Answer', 'Accepted']
['s158645090', 's076464696']
[211144.0, 110580.0]
[2213.0, 595.0]
[839, 888]
p02574
u323315992
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['def eratosthenes2(n):\n lim=int(n**0.5)\n d=[i+1 for i in range(2,n,2)]\n D=[2]*(n+1)\n D[0]=D[1]=-1\n while True:\n p=d[0]\n if lim<p:\n for x in d:\n D[x]=x\n break\n D[p]=p\n d2=[]\n for x in d:\n if x%p!=0:\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s346164406', 's529034061', 's757380045']
[127348.0, 127508.0, 127272.0]
[1802.0, 447.0, 913.0]
[486, 341, 294]
p02574
u328811800
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['import sys\n\ndef gcd(x, y):\n if x % y == 0:\n return y\n else:\n return gcd(y, x % y)\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncount= [0] * (1000001)\nsetwise_gcd = A[0]\nfor i in range(0,N):\n count[A[i]]+= 1\n setwise_gcd = gcd(setwise_gcd, A[i])\n\n\nif setwise_gcd !=...
['Time Limit Exceeded', 'Accepted']
['s186257254', 's376481673']
[127368.0, 150544.0]
[2206.0, 951.0]
[816, 470]
p02574
u347640436
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd\nfrom functools import reduce\n\ndef make_prime_table(n):\n sieve = list(range(n + 1))\n sieve[0] = -1\n sieve[1] = -1\n for i in range(4, n + 1, 2):\n sieve[i] = 2\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i] != i:\n continue\n for j in ...
['Runtime Error', 'Accepted']
['s637951150', 's666129521']
[121952.0, 121816.0]
[453.0, 684.0]
[1038, 571]
p02574
u391725895
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['def gcc(x, y):\n if x == 0:return y\n return gcc(y % x, x)\n\nN = int(input())\nA = list(map(int, input().split()))\n\ng = 0\n\nA.sort()\n\nfor item in A:\n g = gcc(g, item)\n\nif g != 1:\n print("not coprime")\n exit()\n\nprimes = []\n\nis_prime = [True] * 1100000\nprimes = []\n\nis_prime[0] = is_prim...
['Runtime Error', 'Accepted']
['s039071947', 's052657814']
[127064.0, 127032.0]
[898.0, 1431.0]
[1022, 1014]
p02574
u397080265
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['mod=10**9+7\nn=int(input())\na=list(map(int,input().split()))\na.sort()\ng=a[0]\nd=defaultdict(int)\nfor i in a:\n g=math.gcd(g,i)\n d[i]+=1\nif g>1:\n print("not coprime")\np=[0]*(a[-1]+1)\nch=0\nfor i in range (2,a[-1]+1):\n if p[i]==1:\n continue\n p[i]=1\n ans=0\n for j in range (i,a[-...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s272317811', 's291199803', 's731577932', 's203279173']
[126432.0, 132636.0, 126488.0, 134332.0]
[562.0, 744.0, 564.0, 1711.0]
[442, 530, 676, 569]
p02574
u408325839
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["import numpy as np\nfrom numba import njit\ndef main():\n N = int(input())\n nlist = np.array(list(map(int, input().split())))\n\n def gdc(x, y):\n b = max(x, y)\n s = min(x, y)\n r = b % s\n if r == 0:\n return s\n else:\n return gdc(s, r)\n\n scp ...
['Time Limit Exceeded', 'Accepted']
['s560327357', 's860237200']
[208796.0, 208632.0]
[2208.0, 1045.0]
[786, 785]
p02574
u413165887
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["n = int(input())\na = list(map(int, input().split()))\n\nfrom math import gcd\n\nr = a[0]\nfor i in a[1:]:\n r = gcd(r, i)\n\nc = [0 for _i in range(10**6+1)]\nh = True\nfor i in a:\n num = i\n for j in range(2, int(num**.5)+1):\n if num%j == 0:\n c[j] += 1\n if c[j] >= 2:\n ...
['Wrong Answer', 'Accepted']
['s060417644', 's164370392']
[127464.0, 132728.0]
[1217.0, 626.0]
[624, 377]
p02574
u414050834
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["import math\nfrom functools import reduce\nk=10**6+1\ndef judge(n,a):\n c=[0]**k\n for x in a:\n c[x]=+1\n t=any(sum(c[i::i])>1 for i in range(2,k))\n t+=reduce(gcd,a)>1\n return ['pairwise','setwise','not'][t]+' coprime'\nn=int(input())\na=list(map(int,input().split()))\nprint(judge(n,a))", "from math import...
['Runtime Error', 'Accepted']
['s316024098', 's928939056']
[133008.0, 133172.0]
[250.0, 627.0]
[286, 614]
p02574
u423624748
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['#include<bits/stdc++.h>\n\ntemplate<uint32_t N = 10\'000\'000>\nstruct Sieve_of_Eratosthenes{\n using u32 = uint32_t;\n std::vector<u32> factor;\n Sieve_of_Eratosthenes(){\n factor.resize(N+1);\n for(u32 p=2;p<=N;++p){\n if(factor[p])continue;\n factor[p] = p;\n for(u32 x=p+p;x<=N;x+=p){\n ...
['Runtime Error', 'Accepted']
['s136342203', 's711645435']
[9012.0, 147088.0]
[29.0, 1245.0]
[1295, 843]
p02574
u437215432
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["def GCD(m, n):\n while n != 0:\n m, n = n, m % n\n return m\n\ndef f(a):\n n = len(a)\n pairwise_coprime = True\n for i in range(n - 1):\n for j in range(i + 1, n):\n if GCD(a[i], a[j]) != 1:\n pairwise_coprime = False\n break\n if pairwise_...
['Wrong Answer', 'Accepted']
['s083322313', 's004647831']
[127156.0, 127300.0]
[244.0, 902.0]
[645, 1002]
p02574
u475402977
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["def gcd(x, y):\n if y == 0:\n return x\n else:\n return gcd(y, x % y)\n\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n ...
['Runtime Error', 'Accepted']
['s113660434', 's166425838']
[9000.0, 127712.0]
[27.0, 531.0]
[832, 1076]
p02574
u512212329
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd\nfrom functools import reduce\nfrom collections import defaultdict\n\n\ndef facs(n):\n \n yield 2\n for x in range(3, n, 2):\n yield x\n\n\ndef main():\n input() # N\n array = [int(x) for x in input().split()]\n MAX_A = 10 ** 6 + 1\n histogram = defaultdict(int)\n ...
['Time Limit Exceeded', 'Accepted']
['s726199932', 's988135092']
[133320.0, 133152.0]
[2144.0, 431.0]
[833, 706]
p02574
u522293645
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd \n# --------------------------------------------------------------\n\n\n\n# prs = []\n# is_prime = [True] * (n + 1)\n# is_prime[0] = False\n# is_prime[1] = False\n\n# if not is_prime[i]:\n# continue\n# for j in range(i*2, n+1, i):\n# is_prim...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s229926340', 's235732113', 's915672683', 's956907481', 's679482077']
[132624.0, 132628.0, 90916.0, 134644.0, 132024.0]
[730.0, 420.0, 1959.0, 1189.0, 864.0]
[1097, 1095, 579, 1013, 1068]
p02574
u523087093
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["import math\nL = 10**6 + 1\n\nN = int(input())\nA = list(map(int, input().split()))\nmemo = [0] * L\nflag = 0 \n\nfor a in A:\n memo[a] = 1\n\nfor i in range(2, L):\n if sum(memo[i::i]) > 1:\n flag = 1:\n break\n\ng = 0\nfor i in range(N):\n g = math.gcd(g, A[i])\n\nif flag == 0:\n answer = ...
['Runtime Error', 'Accepted']
['s309126061', 's702629402']
[9044.0, 127624.0]
[24.0, 862.0]
[443, 443]
p02574
u546338822
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['def main():\n import math\n n = int(input())\n a = sorted(list(map(int,input().split())))\n g=a[0]\n for i in range(1,n):\n g = math.gcd(g,a[i])\n if g > 1:\n print(\'not coprime\')\n return\n d = [1 for i in range(a[-1])]\n for i in range(2,a[-1]):\n if d[i-1] == 1...
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s752440617', 's964161869', 's088071184']
[126840.0, 134508.0, 126940.0]
[2208.0, 1095.0, 1122.0]
[828, 720, 815]
p02574
u547608423
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
['import math\n\nN = int(input())\nA = list(map(int, input().split()))\n\ninf = int(1e6+5)\nC = [0]*inf\n\nfor a in A:\n C[a] += 1\n\npa = True\nse = True\nfor i in range(2, inf):\n cnt = 0\n for j in range(i, inf, i):\n cnt += C[j]\n if cnt > 1:\n pa = False\n if cnt == N:\n se = Fa...
['Time Limit Exceeded', 'Accepted']
['s665956323', 's187067671']
[132816.0, 132612.0]
[2208.0, 860.0]
[417, 390]
p02574
u564589929
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s499231420', 's551536208', 's799840454']
[127584.0, 127772.0, 127868.0]
[776.0, 1372.0, 1345.0]
[1704, 1889, 2140]
p02574
u585963734
2,000
1,048,576
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
["from math import gcd\n\nN=int(input())\nA=list(map(int, input().split()))\n\nc=max(A)\nD=[0]*(c+1)\ndiv=[0]*(c+1)\nP=[]\n\nfor i in range(2,c+1):\n if D[i]==0:\n P.append(i)\n D[i]=i\n for j in P:\n if i*j>c or j>D[i] :\n break\n D[i*j]=j\nf=0\nfor i in A:\n if c>1:\n ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s034195640', 's187293528', 's218381912', 's306596581', 's385922707', 's520156210', 's577570275', 's630453702', 's797206024', 's831035037', 's975763738', 's104241688']
[134788.0, 128032.0, 127840.0, 133024.0, 128136.0, 128192.0, 127832.0, 127980.0, 127220.0, 128116.0, 127800.0, 127640.0]
[2215.0, 808.0, 2207.0, 2156.0, 728.0, 805.0, 900.0, 843.0, 929.0, 821.0, 2224.0, 751.0]
[757, 834, 627, 377, 825, 831, 852, 919, 568, 827, 641, 709]