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
p02762
u324197506
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\n\nn, m, k = map(int, input().split())\n\nfriends = [[0] * n for _ in range(n)]\n\nblocks = [[0] * n for _ in range(n)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n friends[a-1][b-1] = 1\n friends[b-1][a-1] = 1\n\nfor i in range(k):\n c, d = map(int, input().spl...
['Time Limit Exceeded', 'Accepted']
['s344430017', 's412167359']
[2088940.0, 80692.0]
[2247.0, 1097.0]
[734, 942]
p02762
u327532412
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['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)...
['Runtime Error', 'Accepted']
['s033532664', 's978360560']
[29872.0, 46864.0]
[668.0, 1422.0]
[1558, 1557]
p02762
u346812984
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class UnionFind:\n def __init__(self, n_nodes):\n self.parent = [i for i in range(n_nodes)]\n self.rank = [0] * n_nodes\n self.size = [1] * n_nodes\n\n def find(self, x):\n if x == self.parent[x]:\n return x\n else:\n self.parent[x] = self.find(self.paren...
['Runtime Error', 'Accepted']
['s855633051', 's429758103']
[33584.0, 46848.0]
[1582.0, 1072.0]
[1461, 2446]
p02762
u347184682
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k=[int(x) for x in input().rstrip().split()]\nl=[[] for i in range(n)]\nfor i in range(m):\n a,b=[int(x) for x in input().rstrip().split()]\n l[a-1].append(b-1)\n l[b-1].append(a-1)\n\ndone=[0 for i in range(n)]\nans=[0 for i in range(n)]\n\ndef bfs(i):\n cnt=0\n moment=str(i)\n que=[i]\n done[i]=1\n whil...
['Wrong Answer', 'Accepted']
['s773694712', 's097101238']
[25712.0, 112828.0]
[2105.0, 1297.0]
[797, 1048]
p02762
u354126779
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k=map(int,input().split())\nA=[]\nB=[]\nfor i in range(m):\n a,b=map(int,input().split())\n A.append(a)\n B.append(b)\nC=[]\nD=[]\nfor i in range(k):\n c,d=map(int,input().split())\n C.append(c)\n D.append(d)\nunion=[]\nfor i in range(n):\n br=0\n for j in range(len(union)):\n if i+...
['Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s123604661', 's437070457', 's622541751', 's764137813', 's962731540', 's969359831', 's423552668']
[19716.0, 63148.0, 19748.0, 83748.0, 3064.0, 19636.0, 83724.0]
[2105.0, 990.0, 2105.0, 1095.0, 17.0, 2105.0, 1162.0]
[1318, 638, 1394, 634, 759, 1108, 747]
p02762
u357949405
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\nimport sys\ndef input(): return sys.stdin.readline().strip()\n\nDEBUG = False\n\nN, M, K = map(int, input().split())\n\nfriend_matrix = [[0] * N for _ in range(N)]\nblock_matrix = [[0] * N for _ in range(N)]\n\nnum_frineds = [0] * N\nnum_blocks = [0] * N\n\nfor _ in range(M):\n A, B ...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s223331512', 's355232616', 's372272358', 's805999268']
[2087148.0, 2064744.0, 48736.0, 48700.0]
[2247.0, 2261.0, 804.0, 873.0]
[2058, 2803, 2232, 2236]
p02762
u366963613
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["class UnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\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 de...
['Wrong Answer', 'Accepted']
['s949891257', 's141640406']
[24420.0, 16560.0]
[2108.0, 1121.0]
[1808, 1653]
p02762
u368796742
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\n\nn,m,k = map(int,input().split())\nans = [[0]*n for i in range(n)]\n\nfre = [[] for i in range(n)]\nblo = [[] for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n fre[a-1].append(b-1)\n fre[b-1].append(a-1)\nfor i in range(k):\n a,b = map(int,input().sp...
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s274540827', 's552377203', 's172061530']
[2086508.0, 14108.0, 14128.0]
[2249.0, 1118.0, 1118.0]
[1015, 1002, 1018]
p02762
u387774811
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\ninput = sys.stdin.readline\nif 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 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...
['Runtime Error', 'Accepted']
['s879160371', 's050135398']
[2940.0, 17820.0]
[17.0, 735.0]
[841, 930]
p02762
u413165887
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n, m, k = map(int , input().split())\ndif = set([i for i in range(1, n+1)])\nm_list = [[] for _ in range(n+1)]\nuni = [i for i in range(n+1)]\nab = sorted([list(map(int, input().split())) for _ in range(m)])\ncd = [list(map(int, input().split())) for _ in range(k)]\nfor i in range(m):\n a, b = ab[i]\n m_list[a]...
['Wrong Answer', 'Accepted']
['s012011253', 's414391946']
[70160.0, 60504.0]
[2108.0, 1053.0]
[863, 1030]
p02762
u414920281
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.setrecursionlimit(1000000000)\nn,m,k=map(int,input().split())\nstock=[set() for i in range(n)]\nter=[0]*n\nans=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n stock[a-1].append(b-1)\n stock[b-1].append(a-1)\n ans[a-1]-=1\n ans[b-1]-=1\ndef dfs(j,k):\n size[k]+=1\n for n...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s077012906', 's503976930', 's574535494', 's699109809']
[33736.0, 33660.0, 33740.0, 49588.0]
[227.0, 231.0, 234.0, 646.0]
[753, 751, 708, 748]
p02762
u426764965
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\nsys.setrecursionlimit(200100)\ndef abc157_d():\n N, M, K = map(int, input().split())\n fr = [set() for _ in range(N)]\n for _ in range(M):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n fr[a].add(b)\n fr[b].add(a)\n bl = [set() for _ in range(N)]\n for _ ...
['Wrong Answer', 'Accepted']
['s405534139', 's930495897']
[103224.0, 77076.0]
[1017.0, 983.0]
[942, 1021]
p02762
u432251613
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['def main():\n \n class UnionFind:\n def __init__(self, n):\n \n self.par = [i for i in range(n)]\n self.rank = [0] * n\n self.size = [1] * n\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s036443027', 's090690555', 's163958033', 's634987142', 's711238942', 's837221161', 's910299939']
[16612.0, 18584.0, 16616.0, 19052.0, 16616.0, 19056.0, 15696.0]
[1403.0, 1372.0, 1390.0, 1396.0, 1532.0, 1470.0, 1224.0]
[1896, 1775, 1760, 1775, 1657, 1766, 1705]
p02762
u451012573
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\nN, M, K = map(int, input().split())\nsys.setrecursionlimit(N + 1)\n\nF, B = {}, {}\nfor i in range(N):\n F[i] = set()\n B[i] = set()\n\nfor _ in range(M):\n x, y = map(int, input().split())\n F[x - 1].add(y - 1)\n F[y - 1].add(x - 1)\n\nfor _ in range(K):\n x, y = map(int, input().split(...
['Time Limit Exceeded', 'Accepted']
['s903057994', 's589182666']
[105028.0, 53600.0]
[2109.0, 1650.0]
[671, 1485]
p02762
u455408345
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['nmk=input("").split(" ")\nn=int(nmk[0])\nm=int(nmk[1])\nk=int(nmk[2])\nlistin=[-1]*n\nlistf=[]\nlistb=[]\nfor i in range(n):\n listf+=[[]]\n listb+=[[]]\nfor i in range(m):\n ab=input("").split(" ")\n a=int(ab[0])-1\n b=int(ab[1])-1\n listf[a]+=[b]\n listf[b]+=[a]\nfor i in range(k):\n ab=inpu...
['Wrong Answer', 'Accepted']
['s241886933', 's834222967']
[63612.0, 53288.0]
[2207.0, 735.0]
[897, 1528]
p02762
u455629561
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import defaultdict\n\nn, m, k = map(int, input().split())\nfriend = defaultdict(list)\nblock = defaultdict(list)\nfor i in range(m):\n a, b = map(int, input().split())\n if a > b:\n a, b = b, a\n friend[a].append(b)\nfor i in range(k):\n a, b = map(int, input().split())\n if a >...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s347885543', 's389435440', 's675479087', 's747177171']
[42228.0, 41776.0, 84448.0, 80700.0]
[942.0, 2105.0, 2108.0, 1133.0]
[653, 682, 845, 806]
p02762
u459419927
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from sys import stdin\nimport sys\nsys.setrecursionlimit(20000)\nN,M,K=list(map(int,input().split()))\nfriend_list=[set() for _ in range(N+1)]\nblock_list=[set() for _ in range(N+1)]\ndef friend_tansaku(i,j):\n color.add(j)\n for friend in friend_list[j]:\n if friend not in color:\n if friend ...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s176273373', 's306017574', 's380405074', 's492044614', 's623224641', 's844767720', 's912697138', 's595933557']
[90804.0, 74000.0, 73644.0, 73680.0, 80444.0, 75552.0, 73616.0, 109812.0]
[1081.0, 2108.0, 1102.0, 1054.0, 2108.0, 2108.0, 1300.0, 1605.0]
[872, 882, 839, 845, 831, 843, 878, 1038]
p02762
u459798349
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k=map(int,input().split())\n\nL=[[] for i in range(1+n)]\nN=[]\nNcnt=[0 for i in range(1+n)]\nC=[0 for i in range(1+n)]\n\nfor inp in range(m):\n a,b=map(int,input().split())\n L[a].append(b)\n L[b].append(a)\n\nfor inp in range(k):\n a,b=map(int,input().split())\n N.append((a,b))\n\ndef tansa(x,go...
['Runtime Error', 'Accepted']
['s449526501', 's280442001']
[40628.0, 55640.0]
[2106.0, 883.0]
[925, 930]
p02762
u475503988
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\ninput = sys.stdin.buffer.readline\n\nclass UnionFind():\n \n def __init__(self, n):\n self.n = n\n self.parent = [-1]*(n+1) \n self.rank = [0]*(n+1) \n\n def root(self, x):\n \n if self.parent[x] < 0: \n return x\n else:\n ...
['Time Limit Exceeded', 'Accepted']
['s966438868', 's767100550']
[2000628.0, 47588.0]
[2226.0, 1282.0]
[1599, 2036]
p02762
u480264129
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["n,m,k=map(int,input().split())\nfr=[input() for i in range(m)]\nbl=[input() for i in range(k)]\nrel=[[0]*n for i in range(n)]\nfor i in range(n):\n rel[i][i]=''\nrelmap=[0]*n\nfor l in fr:\n a,b=map(int,l.split())\n rel[a-1][b-1]+=1\n rel[b-1][a-1]+=1\nfor l in bl:\n a,b=map(int,l.split())\n rel[a-1][b-1]-=1\n ...
['Wrong Answer', 'Accepted']
['s511051545', 's055770876']
[1854112.0, 99560.0]
[2223.0, 1780.0]
[353, 1440]
p02762
u486251525
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\ninput = sys.stdin.readline\nN, M, K = map(int, input().split())\n\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(...
['Wrong Answer', 'Accepted']
['s847582814', 's810750991']
[29628.0, 34624.0]
[813.0, 822.0]
[1652, 1672]
p02762
u490553751
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['#template\ndef inputlist(): return [int(j) for j in input().split()]\nfrom collections import Counter\n#template\n\n#Union Find\nN,M,K = inputlist()\ngraph = [[] for _ in range(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):...
['Wrong Answer', 'Accepted']
['s852330877', 's213778660']
[52016.0, 47120.0]
[1508.0, 1512.0]
[1243, 1453]
p02762
u506858457
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['#@YottyPG\u3000Qiita\nfrom collections import deque\n\nN,M,K = map(int,input().split())\nfriend = [list(map(int,input().split())) for _ in range(M)]\nblock = [list(map(int,input().split())) for _ in range(K)]\n\nf = [set() for _ in range(N+1)]\nb = [set() for _ in range(N+1)]\n\nfor i,j in friend:\n f[i].add(j)\n ...
['Runtime Error', 'Accepted']
['s347080624', 's696203624']
[2940.0, 41488.0]
[18.0, 1395.0]
[824, 2011]
p02762
u514383727
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['N, M, K = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(M)]\nCD = [list(map(int, input().split())) for _ in range(K)]\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 ...
['Wrong Answer', 'Accepted']
['s165881468', 's733078188']
[92628.0, 69840.0]
[2109.0, 1360.0]
[2006, 1888]
p02762
u521602455
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.setrecursionlimit(10**6)\nN,M,K=map(int,input().split())\nF=[[] for i in range(N)]\nfor _ in range(M):\n A,B=map(int,input().split())\n F[A-1].append(B-1)\n F[B-1].append(A-1)\nB=[[] for i in range(N)]\nfor _ in range(K):\n C,D=map(int,input().split())\n B[C-1].append(D-1)\n B[D-1].a...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s009843604', 's043725116', 's092670346', 's155001577', 's329717766', 's487071746', 's586237167', 's633235583', 's522212019']
[49012.0, 89960.0, 89980.0, 49048.0, 90120.0, 51572.0, 89980.0, 94204.0, 93344.0]
[1642.0, 2108.0, 2109.0, 1723.0, 2109.0, 1706.0, 2110.0, 2109.0, 1760.0]
[1020, 719, 672, 980, 698, 923, 673, 731, 1463]
p02762
u531603069
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class unionfindtree:\n def __init__(self, n):\n self.root = [i for i in range(n + 1)]\n self.friendcount = [1] * (n + 1)\n\n def getroot(self, x):\n node = self.root[x]\n if node == x:\n return x\n self.root[x] = self.getroot(node)\n return self.root[x]\n\n ...
['Runtime Error', 'Accepted']
['s549814066', 's218329002']
[25264.0, 33072.0]
[814.0, 1024.0]
[1510, 1559]
p02762
u537892680
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['# D - Friend Suggestions\n\nfrom queue import Queue\n\nN, M, K = map(int, input().split())\n\nfriends = [(i, []) for i in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n a, b = a - 1, b - 1\n friends[a][1].append(b)\n friends[b][1].append(a)\n\nblocks = [(i, []) for i in range(N)]\nfor...
['Wrong Answer', 'Accepted']
['s501779206', 's536155386']
[61916.0, 68112.0]
[2107.0, 1854.0]
[869, 1067]
p02762
u539367121
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["def makenetwork():\n for n in range(1,N+1):\n visited=set((n,))\n while visited:\n v=visited.pop()\n D[n].append(v)\n for i in F[v]:\n if i not in D[n]:\n visited.add(i)\n\n\ndef main():\n makenetwork()\n #print(D)\n #ans=[0]*(N+1)\n #for n in range(1, N+1):\n #\tans[n]=len(...
['Wrong Answer', 'Accepted']
['s102649589', 's111990760']
[81456.0, 146380.0]
[2207.0, 1217.0]
[725, 858]
p02762
u540761833
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\ndef input(): return sys.stdin.readline().strip()\nN,M,K = map(int,input().split())\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[...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s815324747', 's997240425', 's683397348']
[64368.0, 52480.0, 26728.0]
[2107.0, 2106.0, 857.0]
[1693, 1676, 1740]
p02762
u557565572
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['\n# # import heapq\n# # from copy import deepcopy\nfrom collections import deque\n# # from collections import Counter\n# # from itertools import accumulate\n# # from itertools import permutations\n# import numpy as np\n# # import math\n\nn, m, k = map(int, input().split())\n# a = list(map(int, input().split()))\n# n ...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s320661532', 's478523053', 's965587985', 's482572840']
[41612.0, 41604.0, 3064.0, 46760.0]
[2109.0, 2106.0, 18.0, 1302.0]
[1084, 1080, 1465, 1463]
p02762
u563676207
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['# input\nN, M, K = map(int, input().split())\n\nFrends = [[] for _ in range(N)]\nFs = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n Frends[a].append(b)\n Frends[b].append(a)\n if a < b:\n Fs[a].append[b]\n else:\n Fs[b].append[a]\n...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s069616419', 's413110824', 's422047109', 's501765817', 's794683172', 's686569331']
[29140.0, 51672.0, 57044.0, 252620.0, 57052.0, 87824.0]
[297.0, 2106.0, 2106.0, 2120.0, 2106.0, 1308.0]
[1168, 1457, 1090, 1556, 1459, 821]
p02762
u566159623
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import defaultdict, deque\nn, m, k = map(int, input().split())\nfriends = defaultdict(list)\nblock = defaultdict(list)\nfor _ in range(m):\n a, b = map(int, input().split())\n friends[a].append(b)\n friends[b].append(a)\nfor _ in range(k):\n c, d = map(int, input().split())\n block[c]....
['Wrong Answer', 'Accepted']
['s017835755', 's554072446']
[62392.0, 144196.0]
[1218.0, 1352.0]
[460, 995]
p02762
u568576853
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\nimport numpy as np\nn,m,k=map(int,input().split())\nlink=[[] for _ in range(n)]\nblock=[[] for _ in range(n)]\nans=[]\ns=[]\nfor i in range(m):\n a,b=map(int,input().split())\n link[a-1].append(b-1)\n link[b-1].append(a-1)\nfor i in range(k):\n a,b=map(int,input().split())\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s335092195', 's807800466', 's411546200']
[75188.0, 1095704.0, 29420.0]
[2112.0, 2170.0, 1007.0]
[699, 649, 1231]
p02762
u584083761
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\nn,m,k = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(m)]\ncd = [list(map(int, input().split())) for _ in range(k)]\n\nf1 = [set() for _ in range(0, n+1)]\nb1 = [set() for _ in range(0, n+1)]\nfb1 = [set() for _ in range(0, n+1)]\nans = [0]*(n+1)\...
['Runtime Error', 'Accepted']
['s672199047', 's243589710']
[180884.0, 183172.0]
[1431.0, 1568.0]
[958, 961]
p02762
u595375942
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["N,M,K=map(int,input().split())\ngraph_data=[[0]*N for _ in range(N)]\nblock_data=[[0]*N for _ in range(N)]\n\nfor _ in range(M):\n i,j=map(int,input().split())\n graph_data[i-1][j-1]=graph_data[j-1][i-1]=1\nfor _ in range(K):\n i,j=map(int,input().split())\n block_data[i-1][j-1]=block_data[j-1][i-1]=1\n\n...
['Wrong Answer', 'Accepted']
['s386887580', 's473374561']
[1970548.0, 19400.0]
[2226.0, 665.0]
[971, 1078]
p02762
u595952233
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["n, m, k = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(m)]\ncd = [list(map(int, input().split())) for _ in range(k)]\n\nblock = [[] for i in range(n)]\nfriend = [[] for i in range(n)]\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] ...
['Time Limit Exceeded', 'Accepted']
['s676762212', 's999346680']
[97820.0, 44404.0]
[2209.0, 555.0]
[1655, 1654]
p02762
u597455618
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\n\n\nclass UnionFind:\n def __init__(self, n):\n self.table = [-1] * n\n\n def _root(self, x):\n stack = []\n tbl = self.table\n while tbl[x] >= 0:\n stack.append(x)\n x = tbl[x]\n for y in stack:\n tbl[y] = x\n return x\n\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s346741259', 's843034860', 's313423362']
[151152.0, 497944.0, 24508.0]
[2155.0, 2134.0, 397.0]
[1331, 676, 1307]
p02762
u609061751
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\ninput = sys.stdin.readline\n \nn,m,k = map(int,input().split())\nab = [set() for _ in range(n)]\ncd = [[] * n for _ in range(n)]\nprint(cd)\n\n \n#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 ...
['Wrong Answer', 'Accepted']
['s449628391', 's432311849']
[64888.0, 64496.0]
[999.0, 976.0]
[1200, 1190]
p02762
u619144316
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["N, M = [int(i) for i in input().split(' ')]\nSC = []\nfor _ in range(M):\n SC.append([int(i) for i in input().split(' ')])\n\nch = [-1] * N\nfor s,c in SC:\n if N >1:\n if s == 1 and c == 0:\n print(-1)\n exit()\n\n if ch[s-1] == -1 or ch[s-1] == c:\n ch[s-1] = c\n else...
['Runtime Error', 'Accepted']
['s855799134', 's488140812']
[3064.0, 98180.0]
[17.0, 1252.0]
[580, 806]
p02762
u624533266
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["from collections import defaultdict\nimport sys\nsys.setrecursionlimit(100000)\n\ndef root(uft, x):\n if uft[x] == x: return x\n uft[x] = root(uft, uft[x])\n return uft[x]\n\ndef union(uft, x, y):\n x = root(uft, x)\n y = root(uft, y)\n if x == y:\n return\n uft[x] = y\n\ndef answer():\n ...
['Runtime Error', 'Accepted']
['s029726203', 's698909157']
[75888.0, 34832.0]
[446.0, 1098.0]
[936, 1106]
p02762
u624696727
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nfrom collections import deque\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\nprintV = lambda x: print(*x, sep="\\n")\nprintH = lambda x: print(" ".join(map(str,x)))\ndef IS(): return sys.stdin.readline()[:-1]\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin...
['Runtime Error', 'Runtime Error', 'Accepted']
['s889206476', 's935959153', 's588247805']
[30184.0, 30148.0, 51728.0]
[290.0, 284.0, 896.0]
[1451, 1451, 1673]
p02762
u625963200
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k=map(int,input().split())\nAB=[list(map(int,input().split())) for _ in range(m)]\nCD=[list(map(int,input().split())) for _ in range(k)]\n\nfriends=[set() for _ in range(n)]\nblocks=[set() for _ in range(n)]\nfor a,b in AB:\n a,b=a-1,b-1\n friends[a].add(b)\n friends[b].add(a)\nfor c,d in CD:\n c,d=c-1,d-1\n ...
['Wrong Answer', 'Accepted']
['s813699070', 's877713373']
[186100.0, 105088.0]
[2111.0, 1914.0]
[634, 1664]
p02762
u626468554
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\n\nN,M, K = map(int,input().split())\nAB = [list(map(int,input().split())) for i in range(M)]\nCD = [list(map(int,input().split())) for i in range(K)]\n\n\n\ndef root(x,li): \n if li[x] == x:\n return x\n else:\n li[x] = root(li[x],li)\n return li[x]\n\n\ndef find(x,y,li):\n r...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s067428531', 's174038850', 's199530598', 's339637309', 's351878324', 's443250057', 's499675228', 's632239300', 's752754441', 's759466274', 's770416571', 's918595095', 's506108288']
[63788.0, 64972.0, 109488.0, 63672.0, 60636.0, 67612.0, 63424.0, 61396.0, 63676.0, 63796.0, 59816.0, 60100.0, 108752.0]
[1218.0, 1276.0, 1398.0, 1065.0, 757.0, 1183.0, 1188.0, 913.0, 1105.0, 1070.0, 667.0, 871.0, 1200.0]
[1146, 1154, 1223, 1123, 1174, 1227, 1117, 1164, 1152, 1095, 1164, 1164, 1229]
p02762
u626881915
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k = map(int, input().split())\n\ng = [[] for i in range(n+1)]\nf = [0]*(n+1)\nb = []\nfor i in range(m):\n u, v = map(int, input().split())\n g[u].append(v)\n g[v].append(u)\n f[u] += 1\n f[v] += 1\nfor i in range(k):\n b.append(map(int, input().split()))\n\ncount = 0\nrenketu_list = [-1]*(n+1)\nrenketu_siz...
['Runtime Error', 'Accepted']
['s889159876', 's314299347']
[69320.0, 69892.0]
[914.0, 1247.0]
[935, 943]
p02762
u628262476
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n, m, k = map(int, input().split())\n\nf_adj_list = [[] for i in range(n)]\nb_adj_list = [[] for i in range(n)]\n\nfor i in range(m):\n _, __ = map(int, input().split())\n _ -= 1\n __ -= 1\n f_adj_list[_].append(__)\n f_adj_list[__].append(_)\n \nfor j in range(k):\n _, __ = map(int, input().split())\n _ -= 1...
['Runtime Error', 'Accepted']
['s858301025', 's174007446']
[54888.0, 57736.0]
[816.0, 768.0]
[1058, 1107]
p02762
u652583512
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
[" class union_find():\n def __init__(self, n):\n self.par = [i for i in range(n + 1)]\n self.rank = [1 for i in range(n + 1)]\n self.size = [1 for i in range(n + 1)]\n \n def find(self, c):\n if self.par[c] == c:\n return c\n \n ...
['Runtime Error', 'Accepted']
['s627305445', 's678974900']
[2940.0, 65412.0]
[17.0, 1478.0]
[2094, 1840]
p02762
u657786757
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n,m,k = list(map(int,input().split()))\nans_l =[0 for _ in range(n)] \nfriend = [[] for _ in range(n)]\nfriend_line =[i for i in range(n)]\nfor _ in range(m):\n a,b= list(map(int,input().split()))\n if not a-1 in friend[b-1]:\n friend[a-1].append(b-1)\n friend[b-1].append(a-1)\n\nnum = 0\nwhile(nu...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s221095069', 's514831144', 's936595180', 's006860926']
[34352.0, 53552.0, 43052.0, 18388.0]
[2106.0, 2107.0, 2106.0, 834.0]
[752, 831, 750, 2884]
p02762
u664373116
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.setrecursionlimit(10**5)\ntotal=0\ndef bfs(ind,num):\n kouho=friends[ind]\n \n for i in kouho:\n if sans[i]!=-1:\n continue\n num+=1\n sans[i]=sans[ind]\n l[sans[ind]].append(i)\n num+=bfs(i,0)\n return num\nn,m,k=list(map(int,input().split()))...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s089794178', 's203123749', 's558415953', 's661781867', 's756906874', 's899368738', 's928838783']
[148324.0, 160100.0, 158428.0, 145124.0, 160060.0, 2940.0, 165776.0]
[1392.0, 1440.0, 1481.0, 1351.0, 1385.0, 2107.0, 1617.0]
[1083, 1083, 962, 939, 897, 43, 1139]
p02762
u677121387
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque,Counter\nimport sys\ninput = sys.stdin.readline\n\nn,m,k = map(int,input().split())\nfrd = [[] for _ in range(n)]\nblk = [[] for _ in range(n)]\nfor _ in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n frd[a].append(b)\n frd[b].append(a)\nfor _ in range(k):\...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s373731322', 's385537858', 's535732119', 's575236104', 's629076495']
[47832.0, 47836.0, 30936.0, 47832.0, 33032.0]
[2106.0, 2106.0, 2105.0, 2106.0, 958.0]
[895, 857, 817, 902, 813]
p02762
u678167152
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["N, M, K = map(int, input().split())\nfriend = [[] for _ in range(N+1)]\nblock = [[] for _ in range(N+1)]\n\nfor i in range(M):\n A,B = map(int, input().split())\n friend[A].append(B)\n friend[B].append(A)\n\nfor i in range(K):\n C,D = map(int, input().split())\n block[C].append(D)\n block[D].append(C)\n#print(f...
['Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s628329079', 's840543893', 's968062447']
[48468.0, 43852.0, 49328.0]
[2109.0, 2106.0, 756.0]
[1014, 747, 1103]
p02762
u695079172
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['#import sys\n\n\nclass UF:\n \n def __init__(self,n):\n self.n = n\n self.parents = [-1] * (n+1) \n self.rnks = [0] * (n+1)\n\n def find(self,n):\n if self.parents[n] < 0:\n return n\n else:\n self.parents[n] = self.find(self.parents[n])\n r...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s261864440', 's281234596', 's939079396', 's323959551']
[9384.0, 10280.0, 3188.0, 20348.0]
[986.0, 889.0, 18.0, 1041.0]
[2246, 2192, 1861, 2198]
p02762
u697696097
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nfrom io import StringIO\nimport unittest\n\nclass UnionFind():\n \n \n def __init__(self, n):\n self.n = n\n \n \n self.root = [-1]*(n+1)\n \n self.rnk = [0]*(n+1)\n\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s023060071', 's469241153', 's300573930']
[5712.0, 5636.0, 17096.0]
[43.0, 42.0, 781.0]
[2415, 2717, 2414]
p02762
u700805562
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['n, m, k = map(int, input().split())\nres = []\nfor _ in range(m):\n a, b = map(int, input().split())\n res.append(a)\n res.append(b)\nfor _ in range(k):\n c, d = map(int, input().split())\n res.append(c)\n res.append(d)\nans = [(n-1)]*n\nfor i in range(n):\n p = res.count(i+1)\n ans[i] -= p\nf...
['Wrong Answer', 'Accepted']
['s691813607', 's396418584']
[19736.0, 50040.0]
[2105.0, 1363.0]
[370, 986]
p02762
u727407185
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
[", m, k = [int(x) for x in input().split()]\nfr = [i for i in range(n)]\ndfr = [[] for i in range(n)]\nbl = [[] for i in range(n)]\ndef deref(a):\n s = []\n while True:\n next = fr[a]\n if next == a:\n break\n s.append(a)\n a = next\n for i in s:\n fr[i] = a\n ...
['Runtime Error', 'Accepted']
['s255407293', 's078804343']
[3064.0, 62804.0]
[17.0, 1776.0]
[1219, 945]
p02762
u729133443
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['r=lambda x:p[x]>=0and r(p[x])or x\n(n,m,k),*t=[map(int,t.split())for t in open(0)]\np,f=[-1]*-~n,[-1]*-~n\nfor a,b in t[:m]:\n x,y=r(a),r(b)\n if x!=y:\n if x>y:x,y=y,x\n p[x]+=p[y]\n p[y]=x\n f[a]-=1,\n f[b]-=1,\na=[f[i]-p[r(i)]for i in range(n+1)]\nfor c,d in t[m:]:\n if r(c)==r(d):\n a[c]-=1\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s238627699', 's791679394', 's901112661']
[97112.0, 3064.0, 96856.0]
[861.0, 18.0, 1525.0]
[324, 255, 245]
p02762
u729535891
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['a, b = [0] * m, [0] * m\nc, d = [0] * k, [0] * k\n\ndirect =[[] for _ in range(n)]\nuf = UnionFind(n)\n\nfor i in range(m):\n a[i], b[i] = map(int, input().split())\n a[i] -= 1\n b[i] -= 1\n direct[a[i]].append(b[i])\n direct[b[i]].append(a[i])\n uf.union(a[i], b[i])\n\nfor i in range(k):\n c[i],...
['Runtime Error', 'Accepted']
['s539857816', 's191796407']
[3064.0, 39908.0]
[18.0, 1454.0]
[552, 1679]
p02762
u734442632
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\n\nline = sys.stdin.readline().strip()\nn,m,k = map(int, line.split())\nroots = list(range(n))\nlinked = [0]*n\nfor i in range(m):\n line = sys.stdin.readline().strip()\n a,b = map(int, line.split())\n c, d = min(a,b)-1, max(a,b) - 1\n linked[c] += 1 \n linked[d] += 1\n while c != roots[c...
['Wrong Answer', 'Accepted']
['s430829231', 's474953414']
[16088.0, 36436.0]
[2108.0, 1268.0]
[1049, 1019]
p02762
u736470924
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['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 self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def unite(self, x, y):\n x = self.fin...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s639831184', 's692794319', 's652122194']
[39868.0, 1978612.0, 50052.0]
[1197.0, 2224.0, 1351.0]
[1361, 313, 1286]
p02762
u747602774
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.getrecursionlimit(10**6)\n\nN,M,K = map(int,input().split())\n\npar = [i for i in range(N+1)]\n\n\ndef root(x):\n if par[x] == x:\n return x\n else:\n par[x] = root(par[x])\n return par[x]\n\n\ndef bool_same(x,y):\n return root(x) == root(y)\n\n\ndef unite(x,y):\n x = ...
['Runtime Error', 'Accepted']
['s677169230', 's348599345']
[3064.0, 83148.0]
[18.0, 1172.0]
[963, 950]
p02762
u747703115
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.setrecursionlimit(10**6)\nfrom collections import Counter\n\ndef dfs(nw):\n for nx in B[nw]:\n if V[nx]==-1:\n V[nx] = cnt\n dfs(nx)\n\nF = [[] for _ in range(n)]\nB = [[] for _ in range(n)]\nn, m, k = list(map(int, sys.stdin.readaline().split()))\nfor i in range(m):\n ...
['Runtime Error', 'Accepted']
['s830339319', 's053660338']
[9348.0, 64744.0]
[29.0, 649.0]
[782, 781]
p02762
u755989869
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['\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 return self.parents[x]\n\n def union(self, x, y):...
['Wrong Answer', 'Accepted']
['s426215330', 's917744921']
[14600.0, 14900.0]
[1069.0, 1089.0]
[1476, 1477]
p02762
u762420987
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['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', 'Runtime Error', 'Accepted']
['s270498253', 's273346785', 's261138227']
[8604.0, 19676.0, 14192.0]
[1053.0, 2109.0, 788.0]
[1604, 1126, 1488]
p02762
u762540523
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import defaultdict\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout....
['Runtime Error', 'Accepted']
['s793348210', 's653014741']
[5820.0, 44192.0]
[49.0, 1235.0]
[3785, 1936]
p02762
u780475861
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['\n\nimport sys\nreadline = sys.stdin.readine\n\nN, M, K = map(int, readline().split())\n\nF = [[] for _ in range(N + 1)]\nfor _ in range(M):\n a, b = map(int, readline().split())\n F[a].append(b)\n F[b].append(a)\n\nB = [[] for _ in range(N + 1)]\nfor _ in range(K):\n c, d = map(int, readline().split())\n...
['Runtime Error', 'Accepted']
['s918712039', 's514455504']
[3064.0, 51732.0]
[18.0, 679.0]
[1079, 1080]
p02762
u788068140
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\n\n\nN,M,K = map(int,input().split())\n\nARR = []\nBRR = []\nfor i in range(M):\n ARR.append(list(map(int,input().split())))\n\nfor i in range(K):\n BRR.append(list(map(int,input().split())))\n\n#\n# N = 10\n# M = 9\n# K = 3\n# ARR = [\n# [10, 1],\n# [6, 7],\n# [8, 2],\...
['Wrong Answer', 'Accepted']
['s900009683', 's666363406']
[106568.0, 90688.0]
[2114.0, 1975.0]
[2051, 2286]
p02762
u788703383
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nsys.setrecursionlimit(10*9)\n\nn,m,k = map(int,input().split())\nparent_of = [-1 for _ in range(n)]\n#print(parent_of)\ndef root_of(x):\n\tif parent_of[x] < 0:\n\t\treturn x\n\telse:\n\t\tparent_of[x] = root_of(parent_of[x])\n\t\treturn parent_of[x]\n\ndef unite(x,y):\n\ttop_root_x = root_of(x)\n\ttop_roo...
['Runtime Error', 'Accepted']
['s782934083', 's838161910']
[7820.0, 13388.0]
[469.0, 1003.0]
[1055, 1057]
p02762
u790012205
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["from collections import deque\nN, M, K = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(M)]\nCD = [list(map(int, input().split())) for _ in range(K)]\n\nF = [[[] for _ in range(2)] for _ in range(N)]\nfor m in AB:\n F[m[0] - 1][0].append(m[1] - 1)\n F[m[1] - 1][0].append(m[0] - ...
['Time Limit Exceeded', 'Accepted']
['s771272677', 's282527909']
[105860.0, 129544.0]
[2112.0, 1288.0]
[1002, 769]
p02762
u797994565
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class UnionFind:\n def __init__(self, N):\n self.rank = [0] * N\n self.parent = [i for i in range(N)]\n self.n = N\n self.size = [1 for i in range(N)]\n def find(self, x):\n if self.parent[x] == x:\n return x\n else:\n self.parent[x] = self.find(se...
['Wrong Answer', 'Accepted']
['s823456481', 's469738161']
[17068.0, 16540.0]
[1307.0, 1209.0]
[1548, 1523]
p02762
u814986259
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import collections\nN, M, K = map(int, input().split())\nAB = [tuple(map(int, input().split())) for i in range(M)]\n\nCD = [tuple(map(int, input().split())) for i in range(K)]\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 ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s046162431', 's845976664', 's856266603', 's123175536']
[107240.0, 138628.0, 107184.0, 138588.0]
[1086.0, 1459.0, 1338.0, 1663.0]
[1309, 1301, 1307, 1321]
p02762
u824295380
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['N, M ,K= map(int, input().split())\na=[0]*M\nb=[0]*M\nc=[0]*K\nd=[0]*K\n\nfor i in range(M):\n a[i], b[i] = map(int, input().split())\nfor i in range(K):\n c[i], d[i] = map(int, input().split())\nl=[-1]*(N+1)\nla=N\n\nfor i in range(M):\n if l[a[i]]<0 and l[b[i]]<0:\n l[a[i]]=la\n l[b[i]]=la\n ...
['Wrong Answer', 'Accepted']
['s445788135', 's479217445']
[20644.0, 47076.0]
[2105.0, 1162.0]
[1361, 895]
p02762
u834269725
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class Node():\n def __init__(self, v):\n self.value = v\n self.friends = set()\n self.blocked = set()\n\nn, m, k = list(map(int, input().split()))\nlink = {i: Node(i) for i in range(1, n+1)}\ngroups = []\nfor _ in range(m):\n a, b = list(map(int, input().split()))\n link[a].friends.add(b...
['Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s244556809', 's641412837', 's905373348', 's069504477']
[103712.0, 93472.0, 93532.0, 74828.0]
[2109.0, 2109.0, 2109.0, 1283.0]
[1046, 881, 962, 1366]
p02762
u852613820
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\ninput = sys.stdin.readline\n\ndef main():\n N, M, K = map(int, input().split())\n\n friends = [[False] * N for _ in range(N)]\n print(friends)\n\n for _ in range(M):\n A, B = map(int,input().split())\n friends[A-1][B-1] = True\n friends[B-1][A-1] = True\n\n print(friend...
['Wrong Answer', 'Accepted']
['s556912842', 's851817755']
[1975284.0, 38076.0]
[2226.0, 1120.0]
[351, 2084]
p02762
u860002137
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class UnionFind:\n def __init__(self, n):\n self.root = list(range(n + 1))\n self.size = [1] * (n + 1)\n\n def find(self, x):\n root = self.root\n while root[x] != x:\n root[x] = root[root[x]]\n x = root[x]\n return x\n\n def union(self, x, y):\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s075126996', 's963419380', 's985337485', 's524732508']
[13628.0, 329892.0, 133672.0, 19288.0]
[31.0, 2213.0, 2209.0, 672.0]
[1154, 1232, 1366, 1085]
p02762
u872538555
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import deque\n \ndef dfs(friends, x):\n visited = [0] * n\n d = deque([x])\n ans = []\n while d:\n num = d.pop()\n \n #print(num, \'->\',end=\'\')\n \n if visited[num] == 1:\n #print(\'x\')\n continue\n \n visited[num]...
['Time Limit Exceeded', 'Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Accepted']
['s138149359', 's404632793', 's416651101', 's474192648', 's579036896']
[43968.0, 43948.0, 42004.0, 43204.0, 54252.0]
[2107.0, 2106.0, 2109.0, 2106.0, 1859.0]
[1198, 1246, 1259, 1470, 1588]
p02762
u873927631
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['#!/usr/bin/env python3\nimport sys\nfrom collections import defaultdict\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n self.ranks = [0] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s088405930', 's430803217', 's738452530']
[80236.0, 99856.0, 81000.0]
[781.0, 714.0, 1077.0]
[3177, 3209, 3275]
p02762
u888092736
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\nfrom collections import defaultdict\n\nsys.setrecursionlimit(2147483647)\n\n\nclass Graph:\n def __init__(self):\n self.graph = defaultdict(set)\n\n def interconnect(self, u, v):\n self.graph[u].add(v)\n self.graph[v].add(u)\n\n def dfs(self, start):\n seen = set()\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s175068368', 's184981415', 's324984220']
[98640.0, 142756.0, 15548.0]
[2105.0, 2112.0, 1120.0]
[1202, 878, 1228]
p02762
u891847179
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["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)...
['Time Limit Exceeded', 'Accepted']
['s665825941', 's095041546']
[121800.0, 39544.0]
[2110.0, 1602.0]
[2898, 2561]
p02762
u896451538
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import math\nimport itertools\nimport fractions\nimport heapq\nimport collections\nimport bisect\nimport sys\nimport copy\n\nsys.setrecursionlimit(10**9)\nmod = 10**7+9\ninf = 10**20\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readl...
['Wrong Answer', 'Accepted']
['s602570514', 's771332821']
[65172.0, 64328.0]
[1045.0, 1087.0]
[1638, 1621]
p02762
u899308536
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['N,M,K = list(map(int,input().split()))\n\n\n\n\n\nG = [[] for _ in range(N)]\n# print(G)\n\nfor _ in range(M):\n a,b = list(map(int,input().split()))\n G[a-1].append(b-1)\n G[b-1].append(a-1)\n# print(G)\n\nKG = [[] for _ in range(N)]\n\nfor _ in range(K):\n a,b = list(map(int,input().split()))\n KG[a-...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s270618228', 's534966031', 's718465051', 's730661298', 's989665277', 's036652216']
[56872.0, 48872.0, 57664.0, 115292.0, 64176.0, 46588.0]
[2107.0, 884.0, 1033.0, 2107.0, 1115.0, 1176.0]
[1339, 1424, 1493, 1340, 1464, 755]
p02762
u906501980
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['import sys\ninput = sys.stdin.buffer.readline\n\ndef main():\n n, m, k = map(int, input().split())\n parent_f = list(range(n+1))\n rank_f = [0]*(n+1)\n parent_b = list(range(n+1))\n rank_b = [0]*(n+1)\n group_f = [set() for _ in range(n+1)]\n group_b = [set() for _ in range(n+1)]\n group_index...
['Time Limit Exceeded', 'Accepted']
['s698453748', 's556443541']
[139788.0, 15624.0]
[2112.0, 1017.0]
[1495, 1254]
p02762
u915066452
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['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)...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s204352644', 's602903535', 's964964441', 's754128614']
[19248.0, 19248.0, 19248.0, 34544.0]
[526.0, 539.0, 551.0, 1158.0]
[1594, 1594, 1575, 1714]
p02762
u922965680
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import sys\nfrom collections import defaultdict, Counter\n\n\nclass UnionFind(object):\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[...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s145424922', 's327274764', 's703372812']
[73900.0, 83120.0, 88824.0]
[1048.0, 1060.0, 1340.0]
[1752, 1744, 2009]
p02762
u930705402
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["N,M,K=map(int,input().split())\npar=[i for i in range(N+1)]\nsiz=[1 for i in range(N+1)]\nfre=[0 for i in range(N+1)]\nblo=[0 for i in range(N+1)]\nrank=[0 for i in range(N+1)]\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\n\ndef union(a,b):\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s744262137', 's768102178', 's885430897']
[11088.0, 11072.0, 11816.0]
[1117.0, 1150.0, 1057.0]
[776, 781, 921]
p02762
u934529721
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["N, M, K = map(int, input().split())\nF = [[] for _ in range(N)]\nB = [[] for _ in range(N)]\n\nfor _ in range(M):\n a, b = map(int, input().split())\n a, b = a - 1, b - 1\n F[a].append(b)\n F[b].append(a)\n\nprint(F)\n\nfor _ in range(K):\n c, d = map(int, input().split())\n c, d = c - 1, d - 1\n ...
['Wrong Answer', 'Accepted']
['s839931468', 's547269839']
[49980.0, 48364.0]
[1731.0, 1618.0]
[2359, 2205]
p02762
u944643608
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['N, M, K = map(int, input().split())\nans = [0] * N\nfri = [[] for i in range(N)]\nblo = [[] for i in range(N)]\nfor i in range(M):\n a,b = map(int, input().split())\n fri[a-1].append(b-1)\n fri[b-1].append(a-1)\nfor i in range(K):\n c,d = map(int, input().split())\n blo[c-1].append(d-1)\n blo[d-1].append(c-1)\n...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s074947277', 's476937339', 's692642120', 's827985054', 's947828068', 's954130938', 's119607067']
[40496.0, 2940.0, 2940.0, 40516.0, 2940.0, 47592.0, 18760.0]
[2106.0, 17.0, 17.0, 2106.0, 17.0, 2106.0, 1054.0]
[755, 1371, 1089, 919, 1060, 621, 1863]
p02762
u945228737
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["import bisect\nfrom decorator import stop_watch\n\n\n@stop_watch\ndef solve(N, M, K, ABs, CDs):\n friend_map = [[] for _ in range(N + 1)]\n for a, b in ABs:\n friend_map[a].append(b)\n friend_map[b].append(a)\n\n block_map = [[] for _ in range(N + 1)]\n for c, d in CDs:\n block_map[c]...
['Runtime Error', 'Accepted']
['s369835455', 's295171370']
[5092.0, 91724.0]
[49.0, 1279.0]
[2915, 2144]
p02762
u946996108
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['from collections import defaultdict\nimport time\n\nN, M, K = [int(i) for i in input().split(" ")]\n\nfriend_dict = defaultdict(lambda:[])\nblock_dict = defaultdict(lambda:[])\nroot = {}\nnumroot = {}\nnext = 0\n\nfor i in range(M):\n s = input()\n a, b = s.split(" ")\n a = int(a) - 1\n b = int(b) - 1\n\n...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s174899689', 's394927359', 's674165464', 's763373891', 's979959030', 's444199357']
[73564.0, 38284.0, 73564.0, 37008.0, 38288.0, 66624.0]
[2105.0, 2106.0, 2105.0, 2106.0, 2108.0, 1884.0]
[1155, 1247, 1155, 1257, 1247, 1683]
p02762
u959340534
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*n\n self.rank = [0]*n\n \n def find_root(self, e):\n if self.root[e] < 0:\n return e\n else:\n r = self.find_root(self.root[e])\n self.root[e] = r\n return r\n \n def combine(self, e1, e2):\n roo...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s397733538', 's909899950', 's926060779', 's814146750']
[4852.0, 3316.0, 12960.0, 11828.0]
[26.0, 21.0, 1090.0, 1147.0]
[1643, 573, 1655, 1608]
p02762
u995062424
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
["from collections import Counter\n\nclass Unionfind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * (n+1)\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 ret...
['Runtime Error', 'Accepted']
['s830536874', 's494761818']
[9200.0, 19024.0]
[26.0, 693.0]
[1726, 1692]
p02762
u996731299
2,000
1,048,576
An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M _friendships_ and K _blockships_. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User...
['class Unionfind():\n\n def __init__(self,n):\n self.n=n\n self.parents=[-1]*n\n\n def find(self,a):\n if self.parents[a]<0:\n return a\n else:\n self.parents[a]=self.find(self.parents[a])\n return self.parents[a]\n\n\n def union(self,x,y):\n ...
['Wrong Answer', 'Accepted']
['s067029494', 's364656329']
[86800.0, 92824.0]
[1657.0, 1664.0]
[1389, 1446]
p02763
u044220565
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.readline\n#from heapq import heappop, heappush\nfrom collections import defaultdict\n#from itertools import combinations\nsys.setrecursionlimit(10**7)\n\ndef run():\n # import sys\n # A = list(map(int, sys.stdin.readline().split(...
['Runtime Error', 'Accepted']
['s395154967', 's589687506']
[2940.0, 57684.0]
[17.0, 886.0]
[1506, 2781]
p02763
u093861603
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['import bisect\nN=input()\nS=list(input())\nalphabet=[[] for _ in range(26)]\nfor i,s in enumerate(S):\n alphabet[ord(s)-ord(\'a\')].append(i)\nQ=int(input())\nfor _ in range(Q):\n Type,A,B=input().split()\n if Type=="1":\n A=int(A)\n s=S[A-1]\n if s==B:\n continue\n o=o...
['Runtime Error', 'Runtime Error', 'Accepted']
['s281191029', 's659481311', 's462898520']
[28552.0, 28552.0, 30472.0]
[1106.0, 1176.0, 1152.0]
[844, 949, 868]
p02763
u179169725
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
["import sys\nread = sys.stdin.readline\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\ndef read_a_int():\n return int(read())\n\n\ndef read_matrix(H):\n '''\n H is number of rows\n '''\n return [list(map(int, read().split())) for _ in range(H)]\n\n\ndef read_map(H):\n \n retu...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s177003909', 's736764642', 's633509061']
[27252.0, 48460.0, 48460.0]
[1110.0, 815.0, 808.0]
[2202, 2867, 2861]
p02763
u223663729
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
["\n# E - Simple String Queries\n\nfrom bisect import bisect_left, insort_left\nimport sys\ninput = sys.stdin.readline\nOFS = ord('a')\n_ = input()\nS = list(input()[:-1])\n\nD = [[] for _ in [0]*26]\nfor i, s in enumerate(S):\n D[s].append(i)\n\nfor _ in [0]*int(input()):\n Q = input()[:-1].split()\n if Q[0] ...
['Runtime Error', 'Accepted']
['s866553195', 's571351160']
[7816.0, 30856.0]
[28.0, 957.0]
[730, 800]
p02763
u230117534
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['class SegTree:\n def __init__(self, N, S):\n self.N = 2 ** ((N-1).bit_length())\n self.tree = [0 for i in range(self.N * 2 - 1)]\n for i in range(len(S)):\n self.tree[self.N - 1 + i] = 1 << (ord(S[i] - ord("a")))\n\n for i in range(self.N - 2, -1, -1):\n self.tree[...
['Runtime Error', 'Accepted']
['s980250208', 's711333635']
[16136.0, 47400.0]
[72.0, 1118.0]
[1662, 1664]
p02763
u265154666
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['# -*- coding: utf-8 -*-\n\n\n\n\n\n# from helper import elapsed_time\nfrom bisect import bisect_left, insort_left\n\n\nN = int(input())\ns = list(input())\nQ = int(input())\n\n\n# print()\n# print(len(s))\n\n\nd = {i: [] for i in range(26)}\nfor i, c in enumerate(s):\n d[ord(c) - ord("a")].append(i)\n# print(d)\n\...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s429906029', 's828076268', 's779552085']
[28680.0, 3064.0, 28808.0]
[1112.0, 18.0, 1092.0]
[1642, 1636, 1146]
p02763
u306950978
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['from bisect import bisect_left,bisect\nn = int(input())\ns = list(input())\nq = int(input())\nal=[[] for i in range(26)]\nfor i in range(n):\n al[ord(s[i])-ord("a")].append(i)\n\nfor i in range(q):\n a , b , x = input().split()\n if a == "1":\n al[ord(s[int(b)-1])-ord("a")].pop(al[ord(s[int(b)-1])-ord...
['Runtime Error', 'Accepted']
['s620802652', 's832253006']
[34772.0, 35140.0]
[940.0, 1947.0]
[676, 853]
p02763
u334365640
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
['import math\n\nn = int(input())\ns = input()\nS = [ord(i) - 97 for i in s]\nq = int(input())\nHEIGHT = math.ceil(math.log(n) / math.log(2))\nSIZE = 1 << HEIGHT\n\ndef build_tree_for_letter(letter):\n tree = [False for _ in range(2 << HEIGHT)]\n for i in range(1 << HEIGHT):\n tree[i + (1 << HEIGHT)] = Tru...
['Runtime Error', 'Accepted']
['s841533344', 's204706513']
[65672.0, 48152.0]
[2107.0, 693.0]
[1548, 1089]
p02763
u340781749
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
["import sys\n\n\nclass SegTreeSet:\n \n\n def __init__(self, n, initial=0):\n \n n2 = 1 << (n - 1).bit_length()\n self.offset = n2\n self.tree = [initial] * (n2 << 1)\n self.initial = initial\n\n def update(self, i, x):\n \n i += self.offset\n self.tree[...
['Wrong Answer', 'Accepted']
['s389192865', 's768499689']
[18976.0, 32088.0]
[242.0, 490.0]
[1819, 2105]
p02763
u347640436
2,000
1,048,576
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S be...
["# Segment tree (Bitwise Or)\nfrom operator import or_\n\n\nclass SegmentTree:\n _f = None\n _data = None\n _offset = None\n _size = None\n\n def __init__(self, size, f):\n self._f = f\n self._size = size\n t = 1\n while t < size:\n t *= 2\n self._offset = t...
['Runtime Error', 'Accepted']
['s046089488', 's889155241']
[25584.0, 49688.0]
[54.0, 455.0]
[1691, 1765]