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
p03108
u311379832
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def 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 return\n if rank[x] < rank[y]:\n par[x] = y\n else:\n par[y] = x\n if rank[x] == rank[y]:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s030983281', 's690332653', 's803284651']
[32916.0, 34604.0, 34600.0]
[655.0, 690.0, 728.0]
[713, 900, 879]
p03108
u315485238
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = list(map(int, input().split()))\nA=[0] * M\nB=[0] * M\n\nimport math\n\nfor i in range(M):\n A[i], B[i] = list(map(int, input().split()))\n\n \nisland_dict={i+1:i+1 for i in range(N)} \ngroup_dict={i+1:1 for i in range(N)} \n\nanswer = [0] * M\nanswer[-1] = math.factorial(N) // (math.factorial(N-2)*2)\n\n \...
['Runtime Error', 'Runtime Error', 'Accepted']
['s144196084', 's254619335', 's380642565']
[38500.0, 48364.0, 56628.0]
[776.0, 811.0, 688.0]
[887, 1089, 953]
p03108
u319818856
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind:\n def __init__(self, size: int):\n self.__root = [-1 for _ in range(size)]\n self.__size = [1 for _ in range(size)]\n\n def find(self, v: int) -> int:\n if self.__root[v] == -1:\n return v\n return self.find(self.__root[v])\n\n def size(self, v: int) ->...
['Wrong Answer', 'Accepted']
['s330577245', 's715117608']
[22188.0, 22932.0]
[1627.0, 810.0]
[1523, 1388]
p03108
u325264482
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFindTree():\n def __init__(self, N):\n self.parent = [-1]*(N+1)\n self.size = [1]*(N+1)\n self.hubensa = N*(N-1)//2\n \n def find(self, i):\n if self.parent[i] == -1:\n group = i\n else:\n group = self.find(self.parent[i]) \n self.p...
['Runtime Error', 'Accepted']
['s123791548', 's744272591']
[12592.0, 20000.0]
[339.0, 581.0]
[1108, 1138]
p03108
u332906195
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['# -*- coding: utf-8 -*-\n\nfrom scipy.misc import comb\nimport sys\nsys.setrecursionlimit(10000000000)\n\n\nclass UnionFind:\n\n def __init__(self, n):\n self.parent = [i for i in range(n + 1)]\n self.depth = [1] * (n + 1)\n self.count = [1] * (n + 1)\n\n def find(self, x):\n if self...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s305348500', 's371989484', 's430341119', 's592816843', 's281014551']
[20264.0, 13232.0, 33688.0, 30652.0, 23284.0]
[321.0, 167.0, 990.0, 1106.0, 818.0]
[1620, 1381, 1380, 1562, 1348]
p03108
u333945892
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["from collections import defaultdict\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\neps = 10**-7\ndef inpl(): return list(map(int, input().split()))\ndef inpl_str(): return list(input().split())\n\n\ndef Find(x): \n global table\n\n...
['Wrong Answer', 'Accepted']
['s552273538', 's168965798']
[39284.0, 39288.0]
[883.0, 873.0]
[1479, 1477]
p03108
u334712262
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, prod...
['Runtime Error', 'Accepted']
['s678104245', 's823473864']
[51484.0, 51736.0]
[1054.0, 1050.0]
[2254, 2252]
p03108
u341087021
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m = map(int, input().split())\n\nbridges = []\nfor i in range(m):\n bridges.append([int(x) for x in input().split()])\n\ndef root(par, a):\n while par[a] != -1:\n a = par[a]\n return a \n\ndef unite(par, npar, depth, ra, rb):\n if depth[ra] >= depth[rb]:\n npar[ra] = npar[ra] + npar[rb]\n ...
['Runtime Error', 'Accepted']
['s177731863', 's061282229']
[23656.0, 28848.0]
[361.0, 566.0]
[893, 872]
p03108
u342869120
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import math\nfrom collections import defaultdict\n\n\nclass UnionFindTree:\n def __init__(self):\n self.p = {}\n\n def make(self, x):\n self.p[x] = x\n\n def find(self, x):\n if x in self.p:\n if self.p[x] != x:\n self.p[x] = self.find(self.p[x])\n re...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s617585517', 's629293526', 's732513399', 's883286647']
[39820.0, 56676.0, 39816.0, 59696.0]
[1131.0, 1269.0, 1130.0, 917.0]
[1523, 1711, 1554, 1408]
p03108
u343523393
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M=list(map(int,input().split()))\nL=[]\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n\n def find_root(self, x):\n if(self.root[x]<0):\n return x\n else:\n self.root[x] = self.find_root(self.ro...
['Runtime Error', 'Accepted']
['s450438051', 's758392209']
[33328.0, 34300.0]
[964.0, 988.0]
[1346, 1337]
p03108
u368796742
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['from collections import deque\nn,m = map(int,input().split())\nl = [list(map(int,input().split())) for i in range(m)]\nans = n*(n-1)//2\ncheck = [-1]*m\ncheck[-1] = ans\n\ne = [[] for i in range(n)]\n\ndef search(x,y):\n q = deque([])\n dep = list(set(e[x]+e[y]+[x,y]))\n \n \n q.append((x,dep))\n q....
['Wrong Answer', 'Accepted']
['s887340383', 's800935808']
[39856.0, 35780.0]
[2106.0, 777.0]
[630, 978]
p03108
u374103100
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["\n\nimport itertools\nimport collections\nimport bisect\nimport sys\ninput = sys.stdin.readline\n\n# Union find\nclass UnionFind():\n \n \n def __init__(self,size):\n self.table = [-1 for _ in range(size)]\n self.size_table = [1 for _ in range(size)]\n\n \n def find(self, x):\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s112493224', 's360055524', 's372075556', 's123860750']
[41324.0, 41324.0, 41324.0, 41324.0]
[576.0, 2106.0, 2109.0, 594.0]
[2326, 2329, 1912, 2326]
p03108
u384261199
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\nN, M = map(int, input().split())\nab_list = [list(map(int, input().split())) for _ in range(M)]\n\na_list = np.array(ab_list)[:, 0][-1::-1]\nb_list = np.array(ab_list)[:, 1][-1::-1]\n\nhuben = [int((N) * (N-1) * 0.5)]\n\nclass UnionFind():\n def __init__(self, size):\n # self.group holds...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s215863187', 's447294863', 's849145881', 's252416621']
[44548.0, 46468.0, 44528.0, 47196.0]
[2111.0, 2111.0, 1631.0, 1399.0]
[2128, 2148, 2182, 2201]
p03108
u385244248
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import sys\nimport math\nimport string\nimport fractions\nimport random\nfrom operator import itemgetter\nimport itertools\nfrom collections import deque\nimport copy\nimport heapq\nimport bisect\nfrom scipy.misc import comb\n\nMOD = 10 ** 9 + 7\nINF = float('inf')\ninput = lambda: sys.stdin.readline().strip()\n\n\nc...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s013361610', 's191341340', 's258829073', 's313564470', 's458632560', 's718868344', 's842036944', 's160849549']
[41288.0, 41396.0, 40664.0, 41388.0, 42080.0, 15976.0, 40644.0, 37064.0]
[2111.0, 2115.0, 2111.0, 2110.0, 2112.0, 210.0, 2110.0, 930.0]
[2212, 2129, 2226, 2295, 2334, 2298, 2299, 2419]
p03108
u390694622
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M=map(int,input().split())\nunionfindTree = [i for i in range(N)]\nsize = [1 for _ in range(N)]\ninconvenience = N*(N-1)//2\nanswers = [inconvenience] \n#answers[i] should be inconvenience after M-i bridges destroyed.\n\ndef root(x):\n p = unionfindTree[x]\n if x==p:\n return(p)\n else:\n uni...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s205058922', 's356883815', 's736347082', 's922170507', 's317164559']
[25820.0, 28216.0, 21352.0, 25064.0, 24868.0]
[502.0, 520.0, 324.0, 558.0, 616.0]
[1049, 897, 961, 956, 1041]
p03108
u390958150
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\n\nn,m = [int(i) for i in input().split()]\na = np.array([0]*m)\nb = np.array([0]*m)\nans = np.array([0]*m)\nans[m - 1] = n * (n - 1) / 2\n\nfor i in range(m):\n\ta[i],b[i] = [int(i) for i in input().split()]\n\nclass UnionFind:\n def __init__(self, n):\n \n \n self.par = [-...
['Wrong Answer', 'Accepted']
['s319771628', 's237892616']
[18180.0, 24956.0]
[1917.0, 822.0]
[1305, 1577]
p03108
u391731808
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M = map(int,input().split())\nA = np.zeros(M,dtype=int)\nB = np.zeros(M,dtype=int)\nfor i in range(M):\n A[i],B[i] = map(lambda x:int(x)-1,input().split())\n\n\n%%timeit\ndef check_connect(A,B):\n a = cnt[A]\n b = cnt[B]\n if a==-1 and b==-1:\n connect.append([A,B])\n cnt[A] = len(connect)...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s557617127', 's589282770', 's866257493', 's051948605']
[3064.0, 10996.0, 3188.0, 48800.0]
[18.0, 335.0, 18.0, 866.0]
[1051, 1023, 1043, 1035]
p03108
u392319141
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind :\n def __init__(self, size) :\n self.rootList = list(range(size))\n self.height = [0] * size\n\n def getRootList(self) :\n return self.rootList\n\n def root(self, index) :\n if self.rootList[index] == index : \n return index\n rootIndex = self.r...
['Wrong Answer', 'Accepted']
['s696371012', 's640833669']
[24736.0, 26228.0]
[2105.0, 800.0]
[1638, 1708]
p03108
u405660020
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import sys\nsys.setrecursionlimit(10**7)\n\nn, m = map(int, input().split())\n\npar = [i for i in range(n+1)]\nrank = [0]*(n+1)\nsize = [1]*(n+1)\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\ndef same(x, y):\n return root(x) == root(y)\n\...
['Runtime Error', 'Accepted']
['s510455536', 's942264713']
[33456.0, 33316.0]
[233.0, 545.0]
[900, 1551]
p03108
u407160848
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import sys\n\nsys.setrecursionlimit(2000)\n\ntmp=input().split(" ")\nn = int(tmp[0])\nm = int(tmp[1])\n\nnode_groups = [ i for i in range(n)]\ngroup_sizes = [ 1 for _ in range(n)]\n\nedges = []\nfor i in range(m):\n tmp=input().split(" ")\n edges.append([int(tmp[0])-1, int(tmp[1])-1])\n\nhubensa_list = [0] * (m...
['Runtime Error', 'Runtime Error', 'Accepted']
['s588681170', 's798772644', 's468431126']
[158212.0, 30320.0, 27204.0]
[2104.0, 859.0, 691.0]
[1199, 1351, 1584]
p03108
u413165887
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["n, m = map(int, input().split(' '))\ns = [list(map(int, input().split(' '))) for _ in range(m)]\n\ndic = [x for x in range(n)]\nresult = [int(n*(n-1)/2)]\nfor i in range(1,m):\n if dic[s[-1*i][0]-1] == dic[s[-1*i][1]-1]:\n result.append(result[-1])\n else:\n# p = [x for x in dic if x == dic[s[-1*i...
['Runtime Error', 'Accepted']
['s548874775', 's776923088']
[31468.0, 17688.0]
[331.0, 594.0]
[756, 573]
p03108
u414425367
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def find(tab, a):\n if tab[0][a]==-1:\n return a\n tab[0][a] = find(tab, tab[0][a])\n return tab[0][a]\n\ndef union(tab, a, b):\n p1, p2 = find(tab, a), find(tab, b)\n if p1 != p2:\n tab[0][p1] = p2\n tab[1][p2] += tab[1][p1]\n\ndef size(tab, a):\n return tab[1][a]\n\nN, M = [in...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s237066059', 's996119840', 's315044434']
[3064.0, 4208.0, 42920.0]
[25.0, 31.0, 793.0]
[797, 959, 901]
p03108
u415905784
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["N, M = map(int, input().split())\nBridge= [[int(i) for i in input().split()] for _ in range(M)]\nParent = [int(i) for i in range(N)]\nRank = [1] * N\n \ndef find(x):\n if x == Parent[x]: return x\n else:\n Parent[x] = y = find(Parent[x])\n return y\n \ndef unite(x, y, Total):\n rx, ry = find(x)...
['Wrong Answer', 'Accepted']
['s913514474', 's215350693']
[36316.0, 36312.0]
[516.0, 524.0]
[753, 753]
p03108
u427344224
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind:\n def __init__(self, n):\n self.parent = [i for i in range(n + 1)]\n self.rank = [0 for _ in range(n + 1)]\n self.size = [1] * (n + 1)\n self.group = [[i] for i in range(n + 1)]\n\n def find(self, x):\n # If x is root\n if self.parent[x] == x:\n ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s833149904', 's969033750', 's594891001']
[40012.0, 39756.0, 38536.0]
[1184.0, 1109.0, 851.0]
[2881, 2876, 1949]
p03108
u451017206
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['\nclass DisjointSet:\n def __init__(self):\n self.rank = {}\n self.p = {}\n self._size = {}\n\n def makeSet(self, x):\n self.p[x] = x\n self.rank[x] = 0\n self._size[x] = 1\n\n def same(self, x, y):\n return self.findSet(x) == self.findSet(y)\n\n def unite(...
['Wrong Answer', 'Accepted']
['s998048077', 's609012386']
[157464.0, 47980.0]
[2106.0, 1071.0]
[1388, 1431]
p03108
u472065247
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["def find(x):\n if P[x] < 0:\n return x\n else:\n return P[x]\n\nN, M, *X = map(int,open(0).read().split())\nP = [-1] * (N + 1)\nS = N * (N - 1) // 2\nr = [S]\n\nwhile X:\n b, a = find(X.pop()), find(X.pop())\n if a != b:\n S -= P[a] * P[b]\n if P[a] > P[b]:\n a, b = b, a\n P[a] += P[b]\n P[...
['Runtime Error', 'Accepted']
['s027514959', 's930910096']
[25308.0, 25076.0]
[246.0, 565.0]
[359, 216]
p03108
u474423089
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["class UnionFind:\n def __init__(self,N):\n self.par =[-1 for i in range(N)]\n def find(self,x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n def unite(self,x,y):\n x = self.find(x)\n ...
['Wrong Answer', 'Accepted']
['s243842188', 's880323268']
[35688.0, 35604.0]
[896.0, 849.0]
[1002, 998]
p03108
u476604182
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def cmb(n,r):\n r = min(r, n-r)\n if r==0: return 1\n if r<0: return 0\n over = reduce(mul, range(n, n-r, -1))\n under = reduce(mul, range(1,r+1))\n return over//under\n\nclass UnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n)]\n self.size = [1]*n\n self.rank = [0]*n\n def find(se...
['Runtime Error', 'Accepted']
['s673781601', 's897882354']
[8692.0, 25308.0]
[28.0, 440.0]
[1334, 1046]
p03108
u477320129
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['#!/usr/bin/env python3\nimport sys\n{ % if prediction_success % }\n{ % endif % }\n{ % if mod or yes_str or no_str % }\n\n{ % endif % }\n{ % if mod % }\nMOD = None # type: int\n{ % endif % }\n{ % if yes_str % }\nYES = "None" # type: str\n{ % endif % }\n{ % if no_str % }\nNO = "None" # type: str\n{ % endif % }\n{ % ...
['Runtime Error', 'Accepted']
['s924541914', 's358169676']
[2940.0, 17416.0]
[17.0, 515.0]
[1177, 2313]
p03108
u486448566
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\ninput_int = lambda:int(input())\ninput_ints = lambda:map(int,input().split())\ninput_ints_list = lambda:list(input_ints())\ninput_str = lambda:input()\ninput_strs = lambda:input().split()\ninput_lines = lambda n,input_func:[input_func() for _ in ra...
['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s000335639', 's122838643', 's165406577', 's281872486', 's363171758', 's399100939', 's545288211', 's682532550', 's890314926', 's715798784']
[42900.0, 42848.0, 2078196.0, 42884.0, 2087796.0, 42836.0, 42844.0, 2080372.0, 42800.0, 35536.0]
[2110.0, 2110.0, 2233.0, 2111.0, 2233.0, 2110.0, 2110.0, 2240.0, 2110.0, 842.0]
[4962, 5094, 4976, 5064, 4968, 4914, 5134, 4937, 5122, 3526]
p03108
u487252913
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind:\n def __init__(self, size: int):\n self.parent = [-1 for _ in range(size)]\n self.size = [1 for _ in range(size)]\n\n def unite(self, x, y):\n px = self.find(x)\n py = self.find(y)\n if px == py:\n return\n if self.size[px] > self.size[py]:\n...
['Runtime Error', 'Runtime Error', 'Accepted']
['s002511465', 's249132322', 's048514460']
[16512.0, 16496.0, 15768.0]
[607.0, 596.0, 655.0]
[1424, 1424, 1379]
p03108
u504562455
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import sys\nsys.setrecursionlimit(20000)\nN, M = [int(i) for i in input().split()]\nparent = [i for i in range(N+1)]\nnode_num = [1 for i in range(N+1)]\ndef find(x):\n if parent[x] == x:\n return x\n else:\n parent[x] = find(parent[x])\n return parent[x]\n\nbridge = []\nfor i in range(M):\...
['Runtime Error', 'Accepted']
['s149870660', 's842634682']
[3064.0, 39160.0]
[18.0, 615.0]
[719, 721]
p03108
u512007680
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n, m = map(int, input().split())\nbridges_pre = []\nfor i in range(0,m):\n a, b = map(int,input().split())\n bridges_pre.append([a-1,b-1])\n\nbridges = list(reversed(bridges_pre))\nprint(bridges)\n\ndes = list(range(0,n))\nfor i in range(0,n):\n des[i] = list(range(0,n))\n for j in range(0,n):\n if...
['Wrong Answer', 'Accepted']
['s423874578', 's693825390']
[112440.0, 20652.0]
[2111.0, 637.0]
[1027, 1523]
p03108
u518042385
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m=map(int,input().split())\nl=[]\nfor i in range(m):\n l.append(list(map(int,input().split())))\nl=l[::-1]\nparent=[i for i in range(n+1)]\ndepth=[1 for i in range(n+1)]\ndef find(n):\n if parent[n]==n:\n return n\n else:\n parent[n]=find(parent[n])\n return parent[n]\ndef unite(n,m):\n n1=find(n)\n m...
['Wrong Answer', 'Accepted']
['s777427994', 's650100937']
[35452.0, 34688.0]
[684.0, 714.0]
[656, 690]
p03108
u522726434
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class Union_Find():\n def __init__(self, n):\n self.par = [-1] * n\n def root(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = root(par[x])\n return self.par[x]\n def unite(self, x, y):\n root_x = self.root(x)\n root_y = self.root(y)\n if root_x == root_y:\n ...
['Runtime Error', 'Accepted']
['s752384882', 's051419388']
[18236.0, 24320.0]
[1738.0, 873.0]
[1134, 1465]
p03108
u529180657
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m = map(int,input().split())\na = [0]*m\nb = [0]*m\nfor i in range(m):\n u,v = map(int, input().split())\n a[i] = u-1\n b[i] = v-1\npar = [i for i in range(n)]\nsize = [1]*n\nincomb = [n*(n-1)//2]*m\n\ndef root(x):\n child = x\n root = par[x]\n while True:\n if root == child: \n break\n else:\n ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s512706878', 's603221712', 's897232710', 's623016581']
[20900.0, 2940.0, 2940.0, 32176.0]
[2104.0, 17.0, 20.0, 643.0]
[851, 1005, 1003, 810]
p03108
u532966492
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M=map(int,input().split())\nAB=[list(map(int,input().split())) for _ in range(M)]\nparts=[i for i in range(N)]\nans=[N*(N-1)//2]\nparts_dict=dict([[i,[i]] for i in range(N)])\n\nfor i in range(M-1):\n ab=AB.pop()\n if parts[ab[0]-1]==parts[ab[1]-1]:\n ans.append(ans[-1])\n else:\n a,b=sorted(...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s075395517', 's875817839', 's566481404']
[158604.0, 142760.0, 38180.0]
[2113.0, 2107.0, 772.0]
[682, 663, 1489]
p03108
u533885955
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M=map(int,input().split())\nAB=[list(map(int,input().split())) for i in range(M)]\nABrev = AB[::-1]\nmaxn=int(N*(N-1)/2)\ncango=[]\nfor i in range(M):\n clen=len(cango)\n a=0\n san=0\n for a in range(clen):\n alen=len(cango[a])\n san+=int(alen*(alen-1)/2)\n print(maxn-san)\n j=0\n ...
['Wrong Answer', 'Accepted']
['s667171768', 's494290913']
[30276.0, 34980.0]
[2105.0, 886.0]
[1008, 2368]
p03108
u545368057
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['\nfrom scipy.misc import comb\n\n\nN, M = map(int,input().split())\npairs = []\nfor i in range(M):\n Ai, Bi = map(int,input().split())\n pairs.append([Ai,Bi])\nconnections = []\nans = [int(comb(N,2,exact=True))]\nfor Ai, Bi in pairs[::-1]:\n # connect_flg = False\n ind = []\n for i,connection in enumer...
['Time Limit Exceeded', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s099547380', 's350038019', 's452699456', 's078531637']
[32668.0, 30152.0, 33052.0, 44684.0]
[2110.0, 468.0, 2110.0, 703.0]
[1224, 1224, 1213, 1807]
p03108
u548834738
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = map(int, input().split())\n\npar = list(range(0, N + 1))\nsize = [1] * (N + 1)\nrank = [1] * (N + 1)\n\ndef root(i):\n if par[i] == i:\n return i\n else:\n par[i] = root(par[i])\n return par[i]\n \ndef same(i, j):\n root(i) == root(j)\n \ndef findsize(i):\n size[i] = size[root(i)]\n \ndef unite...
['Wrong Answer', 'Accepted']
['s848241771', 's927827945']
[28236.0, 27176.0]
[704.0, 717.0]
[845, 852]
p03108
u550419600
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["def find_root(components, n):\n if components[n] == n:\n return n\n else:\n root = find_root(components, components[n])\n components[n] = root\n return root\n\nN, M = [int(s) for s in input().split(' ')]\nbridges = []\nfor i in range(M):\n bridges.append([int(s)-1 for s in input(...
['Wrong Answer', 'Accepted']
['s384451156', 's542237508']
[67508.0, 29892.0]
[2105.0, 619.0]
[963, 1058]
p03108
u556225812
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def find(x):\n if par[x] == x:\n return x\n else:\n return find(par[x])\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n\n if x != y:\n if rank[x] < rank[y]:\n par[x] = y\n size[y] += size[x]\n else:\n par[y] = x\n size[x] += size...
['Runtime Error', 'Accepted']
['s959934336', 's918126806']
[3064.0, 24092.0]
[17.0, 668.0]
[1012, 1012]
p03108
u556326496
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["def factorial(n):\n 'n!を返す関数'\n ans = 1\n while(n > 0):\n ans *= n\n n -= 1\n return ans\n\ndef nCr(n, r):\n \n ans = factorial(n) / (factorial(r) * factorial(n-r))\n return int(ans)\n\nclass UnionFind:\n def __init__(self, N):\n \n self.N = N\n self.parent =...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s859818751', 's948985992', 's004713128']
[16448.0, 16472.0, 16948.0]
[846.0, 851.0, 813.0]
[2312, 2312, 2317]
p03108
u559823804
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m=map(int,input().split())\npair=[]\nuf = [-1]*(n+1)\n\ndef root(x):\n if uf[x]<0: \n return x\n else: \n uf[x]=root(uf[x])\n return uf[x]\n\ndef issame(x,y):\n return root(x)==root(y)\n\ndef unite(x,y):\n x=root(x)\n y=root(y)\n ...
['Wrong Answer', 'Accepted']
['s626306282', 's764988322']
[22592.0, 22592.0]
[664.0, 685.0]
[879, 895]
p03108
u560889512
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M=map(int,input().split())\nalist=[]\nblist=[]\nfor i in range(M):\n a,b=map(int,input().split())\n alist.append(a)\n blist.append(b)\nfather=[i for i in range(N+1)]\nrank=[0]*(N+1)\nsize=[1]*(N+1)\n\ndef find(x):\n if x!=father[x]:\n father[x]=find(father[x])\n return father[x]\n\ndef union(x,y):\n x,y=fi...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s442291300', 's605192312', 's095862949']
[16552.0, 18660.0, 19384.0]
[311.0, 575.0, 709.0]
[790, 791, 831]
p03108
u561992253
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import array\nimport time\n\nclass UnionFind :\n def __init__(self, n):\n self.par = array.array('i', range(n))\n self.sizes = array.array('i', [1]*n)\n\n\n def root(self, i):\n if i == self.par[i]:\n return i\n else:\n r = self.root(self.par[i])\n se...
['Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s382496114', 's606517019', 's943507577', 's985279615', 's594739203']
[18100.0, 3064.0, 22472.0, 3064.0, 18568.0]
[2105.0, 18.0, 2105.0, 19.0, 1070.0]
[1511, 1255, 1511, 1495, 1748]
p03108
u562935282
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind:\n def __init__(self, n):\n self.v = [-1 for _ in range(n)] \n\n def find(self, x): \n if self.v[x] < 0: \n return x\n else: \n self.v[x] = self.find(self.v[x]) \n return self.v[x]\n\n def unite(self, x, y): \n x = self.find(x...
['Wrong Answer', 'Accepted']
['s267421261', 's350716867']
[25268.0, 24088.0]
[723.0, 560.0]
[2047, 1181]
p03108
u577170763
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import math\n\n\nclass Solution:\n\n def solve(self, N: int, M: int, bridges):\n\n class UnionFind:\n\n def __init__(self, __N: int):\n self.__N = __N\n self.__par = [i for i in range(__N)]\n self.__num_map = {i: 1 for i in range(__N)}\n\n d...
['Runtime Error', 'Accepted']
['s770389373', 's396832114']
[32612.0, 21744.0]
[348.0, 726.0]
[1813, 1812]
p03108
u578489732
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["# -*- coding: utf-8 -*-\nimport sys\n# ----------------------------------------------------------------\n# Use Solve Function\n\nclass UnionFind:\n def __init__(self, n):\n \n self.par = [i for i in range(n+1)]\n self.size = [1 for i in range(n+1)]\n self.rank = [0] * (n+1)\n\n def _...
['Time Limit Exceeded', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s169653995', 's581666360', 's818587707', 's370465569']
[22928.0, 17416.0, 22676.0, 24088.0]
[2105.0, 2104.0, 1683.0, 815.0]
[1858, 1067, 1859, 1688]
p03108
u593761424
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind(object):\n def __init__(self, n):\n self.parent = {i: i for i in range(n)}\n self.rank = {i: 0 for i in range(n)}\n self.group = {i: [i] for i in range(n)}\n \n def find(self, x):\n if self.parent[x] != x:\n self.parent[x] = self.find(self.parent[x])\n\n...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s302196190', 's741494858', 's861139514', 's535038569']
[1710848.0, 1745688.0, 3192.0, 64532.0]
[2212.0, 2217.0, 19.0, 964.0]
[1558, 1537, 2537, 3329]
p03108
u597455618
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['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']
['s002284373', 's945353150', 's357785332']
[9388.0, 22460.0, 24040.0]
[24.0, 307.0, 306.0]
[1252, 1248, 1246]
p03108
u599547273
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = map(int, input().split(" "))\nAB = [list(map(int, input().split(" "))) for _ in range(M)]\n\n\nclass UnionFind:\n def __init__(self, n):\n self.n = n\n self.per = list(range(n))\n self.point = n*(n-1) // 2\n self.counts = [1]*n\n\n def root(self, x):\n if self.per[x] ==...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s332524564', 's384294781', 's441256804', 's613101477', 's166423804']
[38984.0, 38988.0, 37576.0, 2940.0, 37600.0]
[2105.0, 2105.0, 2105.0, 17.0, 601.0]
[897, 938, 912, 975, 1018]
p03108
u602860891
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import math\n\n\ndef get_group_num(ele):\n for i in range(len(group_list)):\n if ele in group_list[i]:\n return i\n raise Exception('could not find ele in any groups')\n\n\nN, M = list(map(int, input().split()))\nbridge_list = list()\nfor _ in range(M):\n bridge_list.append(list(map(int, in...
['Wrong Answer', 'Accepted']
['s600414547', 's347418654']
[38796.0, 64460.0]
[2106.0, 1278.0]
[971, 1038]
p03108
u603253967
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["def comb(n):\n return (n * (n - 1)) // 2\n\n\ndef main():\n n, m = [int(a) for a in input().split()]\n\n AB = [\n [int(a) for a in input().split()]\n for _ in range(m)\n ]\n\n table = {i: (1, set([i])) for i in range(n)} \n\n current_benrisa = 0\n max_hubensa = comb(n)\n\n rever...
['Wrong Answer', 'Accepted']
['s817267602', 's010567260']
[75204.0, 68800.0]
[877.0, 668.0]
[1216, 1224]
p03108
u606045429
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def comb(n):\n return n * (n - 1) // 2\n\nclass UnionFind():\n def __init__(self, size):\n self.table = [-1 for _ in range(size)]\n\n def find(self, x):\n if self.table[x] < 0:\n return x\n else:\n self.table[x] = self.find(self.table[x])\n return self.ta...
['Wrong Answer', 'Accepted']
['s082296675', 's568737587']
[17232.0, 16900.0]
[685.0, 773.0]
[1143, 1071]
p03108
u607563136
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['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 uni...
['Wrong Answer', 'Accepted']
['s999646859', 's520806958']
[28404.0, 30568.0]
[434.0, 488.0]
[1099, 1144]
p03108
u608088992
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = map(int, input().split())\nBridge= [[int(i) for i in input().split()] for _ in range(M)]\nParent = [int(i) for i in range(N)]\nRank = [1] * N\n \ndef find(x):\n if x == Parent[x]: return x\n else:\n Parent[x] = y = find(Parent[x])\n return y\n \ndef unite(x, y, Total):\n rx, ry = find(x)...
['Runtime Error', 'Accepted']
['s175983906', 's044869347']
[3064.0, 38988.0]
[17.0, 598.0]
[746, 1494]
p03108
u610473220
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["import sys\ninput = sys.stdin.readline\n\n\nclass UnionFindTree:\n def __init__(self, n: int):\n self.n = n\n self.root = [-1] * n\n self.rank = [0] * n\n def findRoot(self, x: int) -> int:\n if self.root[x] < 0:\n return x\n else:\n self.root[x] = self.f...
['Runtime Error', 'Accepted']
['s801737751', 's262012240']
[18996.0, 23288.0]
[146.0, 580.0]
[1696, 1700]
p03108
u614314290
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['\nINF = float("inf")\nMOD = int(1e9 + 7)\ndef int1(n):\n return int(n) - 1\ndef parse(*args):\n return tuple(p(v) for p, v in zip(args, input().split()))\n\n\nclass uft:\n def __init__(self, n):\n self.height = [1] * n\n self.group = [-1] * n\n def root(self, v):\n if self.group[v] < ...
['Runtime Error', 'Accepted']
['s964175512', 's646817130']
[22176.0, 25352.0]
[661.0, 866.0]
[1437, 1590]
p03108
u619819312
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m=map(int,input().split())\na=[list(map(int,input().split()))for i in range(m)][::-1]\nw=[i for i in range(n+1)]\ns=[1]*(n+1)\ndef root(x):\n if w[x]==x:\n return x\n else:\n w[x]=root(w[x])\n return root(w[x])\ndef unite(x,y):\n x=root(x)\n y=root(y)\n if x!=y:\n if s[x]<...
['Wrong Answer', 'Accepted']
['s004451072', 's414634626']
[35436.0, 35884.0]
[764.0, 705.0]
[643, 628]
p03108
u623819879
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["sys.setrecursionlimit(100000)\n\nn, m=map(int, input().split())\na=[0 for i in range(m)]\nb=[0 for i in range(m)]\ng=[list() for i in range(1+n)]\n#print(g)\n\npar=[i for i in range(n)]\ncnt_con=[1 for i in range(n)]\n\ndef root(x):\n if x==par[x]:\n return x\n else:\n par[x]=root(par[x])\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s223988624', 's253969231', 's295200044', 's608818776', 's769655383', 's364826077']
[3064.0, 24220.0, 3064.0, 98592.0, 25928.0, 38080.0]
[19.0, 454.0, 18.0, 2109.0, 2105.0, 867.0]
[946, 1652, 866, 760, 1654, 958]
p03108
u623954643
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N,M = map(int,input().split())\n\na = [0]*M\nb = [0]*M\nans = [0]*M\nfor i in range(M):\n\tA,B = map(int,input().split())\n\ta[i] = A\n\tb[i] = B\n\n\nclass UnionFind():\n \n \n def __init__(self,size):\n self.table = [-1 for _ in range(size)]\n\n \n def find(self,x):\n while self.table[...
['Wrong Answer', 'Accepted']
['s359897209', 's546971813']
[17984.0, 16936.0]
[1024.0, 881.0]
[1754, 1740]
p03108
u650622056
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["N, M = [int(_) for _ in input().split()]\nbridge = [[int(_) for _ in input().split()] for _ in range(M)]\n\nbridge.reverse()\nbridge = bridge[:-1]\n\ninconvenience = N * (N - 1) // 2\ninconvenience_history = [inconvenience]\n\n\nclass UnionFind:\n def __init__(self, N):\n self.par = [i for i in range(N + 1)...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s175170215', 's568431545', 's790777927', 's933690907']
[3064.0, 27300.0, 24540.0, 31528.0]
[17.0, 326.0, 2105.0, 973.0]
[1379, 1799, 1427, 1780]
p03108
u655975843
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import itertools\n\nn, m = map(int, input().split())\npair = []\nfor i in range(m):\n\tpair.append(list(map(int, input().split())))\npair = pair[::-1]\nans = []\nans.append(int(n*(n-1)/2))\n\nclass UnionFind:\n def __init__(self, n):\n self.par = [-1] * (n+1)\n self.rank = [0] * (n+1)\n\n def find...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s211257732', 's723913493', 's956949455', 's503233076']
[34688.0, 35504.0, 37508.0, 35468.0]
[894.0, 862.0, 979.0, 942.0]
[1138, 1130, 1182, 1217]
p03108
u663230781
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def top(L, node):\n current = node\n while L[current] != current:\n current = L[current]\n return current\n\n\ndef main():\n n, m = map(int, input().rstrip("\\n").split(" "))\n\n L = [0]\n counts = {}\n for i in range(1, n + 1):\n L.append(i)\n counts[i] = 1\n\n edges = []...
['Wrong Answer', 'Accepted']
['s743202419', 's048277669']
[60192.0, 60580.0]
[558.0, 1791.0]
[1159, 987]
p03108
u684120680
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\n\nn,m = [int(i) for i in input().split()]\n\nkeiro = np.eye(n)\nab = []\nfor i in range(m):\n a,b = [int(i)-1 for i in input().split()]\n ab.append([a, b])\n keiro[a,b] = 1\n keiro[b,a] = 1\n\nfor i in range(m):\n cnt = 0\n a,b = ab[i]\n keiro[a,b] = 0\n keiro[b,a] = 0\n \n eig, p = np.l...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s385210934', 's544706110', 's246720203']
[58888.0, 42820.0, 43844.0]
[2119.0, 770.0, 831.0]
[495, 758, 851]
p03108
u687044304
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['# -*- coding:utf-8 -*-\n\nclass UnionFind():\n def __init__(self, N):\n \n \n self.parent = [-1] * N\n\n def root(self, A):\n \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...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s264635082', 's471790722', 's769808278']
[16508.0, 16456.0, 16268.0]
[818.0, 791.0, 843.0]
[2769, 2650, 2210]
p03108
u690781906
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def find_root(x):\n if parent[x] == x:\n return x\n else:\n return find_root(parent[x])\n\n\n\ndef unite(x, y):\n x = find_root(x)\n y = find_root(y)\n\n if x != y:\n if rank[x] < rank[y]:\n parent[x] = y\n size[y] += size[x]\n else:\n parent...
['Wrong Answer', 'Accepted']
['s650461600', 's246353145']
[54760.0, 48436.0]
[827.0, 731.0]
[1136, 1102]
p03108
u691896522
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n, m = map(int, input().split())\ndata = []\nfor i in range(m):\n data.append(list(map(int, input().split())))\ndata.reverse()\nclass UnionFind:\n def __init__(self, n):\n \n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n self.size = [1] * (n+1)\n def find(self, x)...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s442661026', 's724759340', 's743818767', 's747448253']
[36772.0, 36076.0, 35056.0, 34980.0]
[1070.0, 1110.0, 894.0, 858.0]
[1732, 1732, 1668, 1682]
p03108
u692746605
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,m=map(int,input().split())\nb=[[int(x) for x in input().split()] for y in range(m)]\nu=n*(n-1)//2\n\ns=[]\na=[u]\n\nfor i in range(m-1,0,-1):\n x=y=-1\n for j in range(len(s)):\n if b[i][0] in s[j]:\n x = j\n if b[i][1] in s[j]:\n y = j\n if x!=-1 and y!=-1:\n break\n\n if x==-1 and y==-1...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s843286127', 's863356857', 's584661206']
[137968.0, 21116.0, 27172.0]
[2105.0, 302.0, 721.0]
[646, 638, 390]
p03108
u708615801
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['from collections import deque\nimport sys\n\nstdin = sys.stdin\ndef li(): return map(int, stdin.readline().split())\n\nN, M = tuple(li())\nstack = []\nfor i in range(M):\n stack.append( tuple(li()) )\n\np_map = {}\nfor i in range(1, N + 1):\n # key: val\n # node_id: parent_id, union_size\n p_map[i] = [i, ...
['Runtime Error', 'Accepted']
['s680546172', 's462601833']
[37648.0, 37732.0]
[1446.0, 802.0]
[989, 1024]
p03108
u709304134
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = map(int, input().split())\nab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(M)]\n \n \nclass UnionFind:\n def __init__(self, n):\n self.parents = [i for i in range(n)]\n self.sizes = [1] * n\n self.rank = [0] * 1\n def find(self, i):\n if self.parents[i] == ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s170747073', 's530408134', 's681562648', 's766381860', 's980935266', 's542103963']
[21368.0, 21352.0, 21352.0, 3064.0, 22968.0, 24876.0]
[372.0, 366.0, 364.0, 20.0, 330.0, 832.0]
[1147, 926, 926, 1208, 1618, 1617]
p03108
u711238850
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import sys\nsys.setrecursionlimit(10**9)\nclass UnionFind:\n def __init__(self,n):\n super().__init__()\n self.par = [-1]*n\n self.rank = [0]*n\n self.tsize = [1]*n\n\n \n def root(self,x):\n if self.par[x] == -1:\n return x \n else:\n self.par[...
['Runtime Error', 'Accepted']
['s506308576', 's731952503']
[18820.0, 28036.0]
[329.0, 751.0]
[1332, 1474]
p03108
u720636500
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['N, M = map(int, input().split())\nlis = [[x, -1] for x in range(1, N + 1)]\nBlis = [list(map(int, input().split())) for _ in range(M)]\ninc = int(N*(N - 1)/2)\nans = [x for x in range(M)]\nans[M - 1] = inc\ndef root(a):\n if lis[a - 1][1] < 0:\n return lis[a - 1][0]\n else:\n k = root(lis[a - 1][1...
['Wrong Answer', 'Accepted']
['s990057835', 's610853067']
[46236.0, 33604.0]
[993.0, 758.0]
[869, 797]
p03108
u729938879
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['\ndef union(group, new_mem):\n if (group[new_mem[0]-1] * group[new_mem[1]-1]) < 0: \n choice = max(group[new_mem[0]-1], group[new_mem[1]-1])\n \n for i in range(len(new_mem)):\n group[new_mem[i]-1] = choice\n \n elif group[new_mem[0]-1] <0 and group[new_mem[1]-1] < 0: ...
['Wrong Answer', 'Accepted']
['s092681077', 's593681687']
[154592.0, 21692.0]
[2105.0, 830.0]
[1720, 1233]
p03108
u737455052
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['from collections import Counter\n\n\nclass UnionFind:\n def __init__(self, node_size):\n self.node_size = node_size\n self.parent = [i for i in range(self.node_size)] # parent\'s number\n self.rank = [0 for i in range(self.node_size)]\n self.size = [1 for i in range(self.node_size)]\...
['Runtime Error', 'Accepted']
['s335762370', 's976096240']
[16776.0, 22768.0]
[308.0, 817.0]
[2042, 2050]
p03108
u740284863
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["from math import *\ndef nCk(n,k):\n if n < k:\n return 0\n return factorial(n)//(factorial(n-k)*factorial(k))\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 ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s083108453', 's794411908', 's199199497']
[27292.0, 31100.0, 31164.0]
[2206.0, 461.0, 475.0]
[1025, 717, 730]
p03108
u758738963
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["#import numpy as np\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(self.parents[x])\n return self.parents[x]\n\n...
['Runtime Error', 'Accepted']
['s291271089', 's567889899']
[18388.0, 40028.0]
[219.0, 645.0]
[1740, 1733]
p03108
u767664985
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["class UnionFind:\n def __init__(self, n):\n self.n = n\n self.parent = [i for i in range(n)] \n self.rank = [1] * n \n self.size = [1] * n \n\n def find(self, x): \n if self.parent[x] == x:\n return x\n else:\n self.parent[x] = self.find(self.p...
['Wrong Answer', 'Accepted']
['s142962265', 's207867435']
[37284.0, 36428.0]
[906.0, 847.0]
[1708, 1701]
p03108
u777207626
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\nn,m = map(int,input().split())\nab = [[int(i) for i in input().split()]for j in range(m)][1:]\n\nans = [int(n*(n-1)/2)]\nl = np.array([i for i in range(1,n+1)])\ns = {i:1 for i in range(1,n+1)}\nfor i in ab[::-1]:\n \n if l[i[0]-1] == l[i[1]-1]:\n ans.append(ans[-1])\n else:\n \n l_a,l...
['Wrong Answer', 'Accepted']
['s581391924', 's580023559']
[44408.0, 39788.0]
[2110.0, 662.0]
[697, 677]
p03108
u782685137
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFindTree:\n def __init__(self, n):\n self._tree = [i for i in range(n)]\n# self._rank = [1] * n\n self._size = [1] * n\n def root(self, a):\n if self._tree[a] == a:return a\n self._tree[a] = self.root(self._tree[a])\n return self._tree[a]\n def is_same_set...
['Wrong Answer', 'Accepted']
['s446100794', 's324571017']
[36908.0, 36908.0]
[938.0, 914.0]
[1128, 1141]
p03108
u782748646
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['data = input().split()\nn = int(data[0])\nm = int(data[1])\nedge=[]\nfor i in range(m):\n tmp = []\n data = input().split()\n tmp.append(int(data[0]))\n tmp.append(int(data[1]))\n edge.append(tmp)\n\nfor i in range(m):\n ans = list(range(1, n+1))\n for j in edge:\n ans = [ans[j[0]-1] if s ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s161467900', 's293481357', 's811707910']
[27836.0, 84336.0, 31092.0]
[2105.0, 2105.0, 570.0]
[500, 517, 851]
p03108
u785578220
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["\nclass UnionFind:\n def __init__(self, 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 self.par[x] = self.find(self.par[x])\n return se...
['Runtime Error', 'Accepted']
['s763425298', 's580495575']
[3192.0, 26352.0]
[18.0, 686.0]
[1835, 1572]
p03108
u788137651
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["from math import factorial\n\n\ndef combination(n, r): \n if n < r:\n return 0\n else:\n return factorial(n)//(factorial(r) * factorial(n-r))\n\n\nclass UnionFind():\n def __init__(self, n):\n self.nodes = [-1] * n \n\n def get_root(self, x):\n \n if self.nodes[x] < 0:...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s283934189', 's513420320', 's817472968']
[24252.0, 3064.0, 24236.0]
[933.0, 17.0, 1010.0]
[1782, 1892, 1849]
p03108
u794543767
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['\nclass UnionFind:\n def __init__(self, length):\n self.par = [-1 for _ in range(length)]\n\n def root(self,x):\n if (self.par[x] < 0 ):\n return x\n else:\n #change connection\n root = self.root(self.par[x])\n self.par[x] = root\n ret...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s269066791', 's580693998', 's785132697', 's294838041']
[16636.0, 18200.0, 3064.0, 23284.0]
[310.0, 356.0, 17.0, 799.0]
[1400, 1528, 1428, 1792]
p03108
u797740860
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n, m = [int(i) for i in input().split(" ")]\ne = []\npar = [i for i in range(0, n + 1)]\ncount = [1] * (n + 1)\nunu = [0] * n\n\nfor i in range(0, m):\n e.append([int(j) for j in input().split(" ")])\n\ndef root(x):\n if par[x] == x:\n return x\n else:\n r = root(par[x])\n par[x] = r\n ...
['Runtime Error', 'Accepted']
['s793140578', 's402143599']
[29536.0, 40452.0]
[639.0, 637.0]
[617, 659]
p03108
u807772568
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import collections\nimport itertools\nimport operator\n\n\nclass UnionFind:\n def __init__(self, elems=None):\n class KeyDict(dict):\n def __missing__(self, key):\n self[key] = key\n return key\n\n self.parent = KeyDict()\n self.rank = collections.defau...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s163820779', 's173323138', 's184018042', 's280766154', 's533527835', 's604885800', 's687319136', 's203770253']
[49600.0, 38284.0, 48824.0, 38308.0, 40628.0, 40832.0, 46748.0, 47096.0]
[1327.0, 535.0, 1519.0, 520.0, 1119.0, 2106.0, 1217.0, 1354.0]
[1966, 1788, 1996, 1966, 1786, 1808, 1973, 2028]
p03108
u814171899
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class UnionFind():\n \n \n def __init__(self,size):\n self.table = [-1 for _ in range(size)]\n self.num = [1 for _ in range(size)]\n\n \n def find(self,x):\n while self.table[x] >= 0:\n \n x = self.table[x]\n return x\n\n \n def union(self,x,y):\n s1 = self.find(x)\n n1 = self.nu...
['Wrong Answer', 'Accepted']
['s642230996', 's671056449']
[36584.0, 36584.0]
[641.0, 646.0]
[1468, 1472]
p03108
u814781830
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\nN, M = list(map(int, input().split()))\nAB = [list(map(int, input().split())) for i in range(M)]\n \nAB.reverse()\n\nreader = np.array([i + 1 for i in range(N)])\nsize = np.array([1 for i in range(N)])\n\ndef root(a):\n if reader[a-1] == a:\n return a - 1\n else:\n return reader[a-1] - 1\n...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s629615219', 's958388867', 's605875678']
[41356.0, 41384.0, 37780.0]
[2110.0, 2113.0, 837.0]
[819, 807, 1283]
p03108
u814986259
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['class unionFind:\n parent = []\n nums = []\n\n def __init__(self, N):\n self.parent = [i for i in range(N)]\n self.nums = [1]*N\n\n def root(self, x):\n if x < 0:\n return(0)\n if self.parent[x] == x:\n return(x)\n else:\n self.parent[x] ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s419382101', 's536973691', 's971761811', 's971869935', 's221819891']
[27176.0, 25868.0, 25928.0, 23204.0, 37268.0]
[849.0, 631.0, 822.0, 635.0, 701.0]
[1214, 1166, 1124, 1161, 1200]
p03108
u815659544
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['#%%\nclass Island:\n def __init__(self,key):\n self.id = key\n self.connectedTo = set()\n\n def addNeighbor(self,nbr):\n self.connectedTo.add(nbr)\n\n def getConnections(self):\n return self.connectedTo.keys()\n\n def getId(self):\n return self.id\n\nclass Graph:\n de...
['Runtime Error', 'Accepted']
['s681267010', 's729887997']
[3188.0, 23244.0]
[18.0, 672.0]
[2078, 1547]
p03108
u820351940
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import numpy as np\nn, m = map(int, input().split())\nab = np.array([list(map(int, input().split())) for x in range(m)]) - 1\n\nto = list(range(n))\nranks = [0] * n\nnodes = [1] * n\n\ndef find(x):\n if to[x] == x:\n return x\n else:\n root = find(to[x])\n to[x] = root\n return root\...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s009804563', 's304152833', 's352761133', 's836477863', 's951731467', 's559167724']
[37920.0, 37900.0, 37900.0, 37900.0, 37804.0, 37904.0]
[853.0, 1110.0, 485.0, 491.0, 837.0, 1074.0]
[934, 858, 928, 938, 934, 915]
p03108
u827202523
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def getN():\n return int(input())\n\ndef getMN():\n a = input().split()\n b = [int(i) for i in a]\n return b[0],b[1]\n\ndef getlist():\n a = input().split()\n b = [int(i) for i in a]\n return b\n\nfrom collections import Counter\nclass UnionFind:\n def __init__(self, n):\n self.par = [i...
['Wrong Answer', 'Accepted']
['s101741999', 's833990119']
[58644.0, 29736.0]
[2105.0, 845.0]
[1428, 1565]
p03108
u837286475
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["\n\n\nclass dset:\n def __init__(self,n):\n self.par = [-1]*n\n\n def size(self,n):\n return -self.par[self.root(n)]\n\n def root(self,n):\n return self.par[n] = root(par[n]) if self.par[n]>=0 else n\n\n def same(self, a, b):\n return self.root(a) == self.root(b)\n\n def __l...
['Runtime Error', 'Accepted']
['s542399408', 's910309600']
[2940.0, 34612.0]
[18.0, 817.0]
[1200, 1274]
p03108
u844005364
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n, m = map(int, input().split())\n\na = []\n\nfor i in range(m):\n a.append(list(map(int, input().split())))\n\nfor i in range(m):\n b = [j for j in range(n)]\n\n aa = a[i+1:]\n aa.sort()\n\n for x, y in aa:\n b[x-1] = min(b[x-1], b[y-1])\n b[y-1] = min(b[x-1], b[y-1])\n\n sum = 0\n ...
['Wrong Answer', 'Accepted']
['s708373633', 's958252586']
[34584.0, 34220.0]
[2108.0, 752.0]
[428, 802]
p03108
u844789719
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["N, M = [int(_) for _ in input().split()]\nAB = [[int(_) for _ in input().split()] for _ in range(M)]\n\nUF = list(range(N + 1))\nSIZE = [0] + [1] * N # 1-indexed\n\n\ndef find(x):\n if UF[x] != x:\n UF[x] = find(UF[x])\n return UF[x]\n\n\ndef unite(x, y):\n if not is_same(x, y):\n X, Y = find(...
['Runtime Error', 'Accepted']
['s897137683', 's505276609']
[34028.0, 31052.0]
[829.0, 784.0]
[875, 1063]
p03108
u845333844
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['import collections\n\nn,m=map(int,input().split())\nll=[]\nfor i in range(m):\n a,b=map(int,input().split())\n ll.append([a,b])\nll.reverse()\n \nmax=n*(n-1)//2\nans=[max]\n\nfor x in range(m):\n edge=ll[:x+1]\n for i in edge:\n l = list(range(n))\n for j in edge:\n if j != i:\n l...
['Wrong Answer', 'Accepted']
['s399546896', 's956397488']
[62316.0, 28620.0]
[2107.0, 745.0]
[450, 1318]
p03108
u845620905
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['def size(A):\n return -1 * par[root(A)]\n\ndef root(A):\n if(par[A] < 0):\n return A\n else:\n par[A] = root(par[A])\n return par[A]\n \ndef connect(A, B):\n A = root(A)\n B = root(B)\n if(A == B):\n return \n if(size(A) < size(B)):\n A, B = B, A\n par[A] += par[B]\n par[B] = A\n \n \nn, m...
['Wrong Answer', 'Accepted']
['s086989698', 's025815013']
[16236.0, 16176.0]
[786.0, 908.0]
[740, 1134]
p03108
u859897687
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
['n,nn=map(int,input().split())\nl=[list(map(int,input().split()))for i in range(nn)]\nl.reverse()\nm=[[1,i] for i in range(n)]\nans=[]\nans.append(n*(n-1)//2)\nfor a,b in l:\n #print(m)\n a-=1\n b-=1\n if m[a][1]==m[b][1]:\n ans.append(ans[len(ans)-1])\n continue\n #m[a][1]!=m[b][1] \n a=m[a][1]\n b=m[b]...
['Wrong Answer', 'Accepted']
['s599992091', 's657958952']
[37888.0, 42428.0]
[2106.0, 892.0]
[522, 493]
p03108
u861466636
2,000
1,048,576
There are N islands and M bridges. The i-th bridge connects the A_i-th and B_i-th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in the order from the first bridge to t...
["N, M = map(int, input().split())\nab = [tuple(map(int, input().split())) for _ in range(M)]\n\nclass UnionFind:\n def __init__(self, size):\n self.rank = [-1]*(size+1)\n self.number = [1]*(size+1)\n \n def find(self, x):\n while self.rank[x] >= 0:\n x = self.rank[x]\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s038302954', 's182634246', 's713316592', 's247882702']
[18948.0, 26068.0, 25504.0, 26068.0]
[322.0, 402.0, 542.0, 407.0]
[999, 1053, 1000, 1048]