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 |
|---|---|---|---|---|---|---|---|---|---|---|
p02630 | u570039786 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\nimport sys\nimport bisect\n\nreadline = sys.stdin.readline\n\n\nN = int(input())\nA = np.array(readline().split(), np.int64)\nA_sort = np.sort(A)\nQ = int(input())\nBC = np.array([np.array(readline().split(), np.int64) for n in range(Q)], np.int64)\n# BC[N][0,1]\n\n\nfor q in range(Q):\n # A = ... | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s061356421', 's160483226', 's173119993', 's910245378', 's508102396'] | [45056.0, 44908.0, 44220.0, 44908.0, 44576.0] | [2209.0, 2207.0, 298.0, 340.0, 805.0] | [591, 576, 347, 591, 1291] |
p02630 | u572179584 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\nl = list(map(int, input()))\nq = int(input())\ncount = 0\n\nfor i in range(q):\n\tcount = 0\n\tb, c = map(int, input().split())\n\tfor a in l:\n\t\tif a == b:\n\t\t\tl[count] = c\n\t\tprint(sum(l))\n\t\tcount++\n', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\nQ = int... | ['Runtime Error', 'Accepted'] | ['s092000230', 's102143252'] | [8724.0, 27164.0] | [27.0, 356.0] | [205, 304] |
p02630 | u580273604 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\nN=int(input())\nA=list(map(int,input().split()))\nA=sorted(A)\nQ=int(input())\nB=[0]*Q;C=[0]*Q\nfor i in range(Q):\n B[i],C[i]=map(int,input().split())\n#print(A)\nD=[0]*10**5;W=[0]*10**5\nfor i in range(10**5):\n D[i]=A.count(i+1)\n W[i]=i+1\n\nfor i in range(Q):\n D[C[i]-1]+=D[B[i]-1]\n ... | ['Wrong Answer', 'Accepted'] | ['s226662127', 's815493654'] | [40852.0, 30068.0] | [2206.0, 399.0] | [374, 301] |
p02630 | u585963734 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\n\nN=int(input())\nA=list(map(int, input().split()))\nQ=int(input())\nB,C=map(int, input().split())\nrep=[i for i, x in enumerate(A) if x == B]\nfor i in range(len(rep)):\n A[rep[i]]=C\nans=np.cumsum(A)\nprint(ans[1])\n\nfor _ in range(Q-1):\n B,C=map(int, input().split())\n rep=[i for i, ... | ['Runtime Error', 'Accepted'] | ['s217023354', 's100281029'] | [38600.0, 21832.0] | [2206.0, 492.0] | [424, 281] |
p02630 | u586662847 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['def resolve():\n N = int(input())\n A = list(map(int, input().split()))\n Q = int(input())\n\n C = Counter(A)\n ANS = 0\n for i in C:\n ANS += i * C[i]\n\n for _ in range(Q):\n B, X = map(int, input().split())\n ANS += X * C[B]\n C[X] += C[B]\n\n ANS -= B * C[B]... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s446494142', 's823601600', 's424545645'] | [21024.0, 21312.0, 24252.0] | [49.0, 53.0, 590.0] | [351, 375, 385] |
p02630 | u593019570 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\n\na = input()\n#print(a)\nq = int(input())\n\nb = []\nfor _ in range(q):\n b.append(input().split())\n#print(b)\nfor i in range(q):\n a.replace(b[i][0],b[i][1],100000)\n c = 0\n d = a.split(" ")\n #print(d)\n for j in range(len(d)):\n c += int(d[j])\n print(c)\n', 'n = in... | ['Wrong Answer', 'Accepted'] | ['s170407238', 's686861004'] | [54168.0, 32920.0] | [2207.0, 382.0] | [290, 367] |
p02630 | u596681540 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["n = int(input())\n\na_list = [int(i) for i in input().split()]\nq = int(input())\n\nary = [0 for _ in range((10 ** 5)+1)]\n\nfor i in a_list:\n ary[i] += i\n\n\nfor _ in range(q):\n b, c = map(int, input().split())\n print('BC', b, c)\n ary[c] += (ary[b]/b)*c\n ary[b] = 0\n ans = int(sum(ary))\n ... | ['Wrong Answer', 'Accepted'] | ['s418835217', 's518812892'] | [20632.0, 20496.0] | [2206.0, 311.0] | [312, 351] |
p02630 | u596743351 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['K = int(input())\nS = len(input())\n\nM = 10**9 + 7\n\nF = [1]\nIF = [1]\nfor i in range(1, K + S + 1):\n F.append((F[-1] * i) % M)\n IF.append((IF[-1] * pow(i, M - 2, M)) % M)\n\ndef nCr(n, r):\n return (F[n] * IF[r] * IF[n-r]) % M\n\nans = 0\nfor i in range(K + 1):\n ans = (ans + nCr(i + S - 1, S - 1) *... | ['Wrong Answer', 'Accepted'] | ['s654513424', 's953449822'] | [59740.0, 20980.0] | [2207.0, 482.0] | [353, 267] |
p02630 | u602773379 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['A=[0]*(10**5+1)\nfor i in a:\n\tA[i]+=1\n\nfor bc in BC:\n\tdiff= bc[1]-bc[0]\n\tSUM+=diff*A[bc[0]]\n\tA[bc[1]]+=A[bc[0]]\n\tA[bc[0]]-=A[bc[0]]\n\tprint(SUM)', '\ndef input_array():\n\treturn list(map(int,input().split()))\n\nn=int(input())\na=input_array()\nq=int(input())\nBC=[input_array() for _ in range(q)]\nSUM=s... | ['Runtime Error', 'Accepted'] | ['s064445328', 's918470666'] | [9392.0, 32128.0] | [26.0, 343.0] | [142, 336] |
p02630 | u606374450 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\n\na = [0] * (10 ** 5 + 1)\nans = sum(A)\n\nfor i in range(N):\n a[A[i]] += 1\n\nfor i in range(Q):\n B, C = map(int, input().split())\n a[C] += a[B]\n a[B] = 0\n ans += a[B] * (C - B)\n print(ans)\n', 'N = int(input())\nA = lis... | ['Wrong Answer', 'Accepted'] | ['s921812575', 's259009887'] | [21056.0, 21128.0] | [470.0, 469.0] | [273, 273] |
p02630 | u608007704 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\n\nN=int(input())\nA=list(map(int,input().split()))\nAdic={}\nfor i in A:\n if Adic.get(i)==None:\n Adic[i]=1\n else:\n Adic[i]+=1\nQ=int(input())\nope=[]\n\nfor i in range(Q):\n ope.append(list(map(int,input().split())))\n\nA=np.array(A)\n\nsum=0\nfor key,value in Adic.items():\n sum+=ke... | ['Wrong Answer', 'Accepted'] | ['s431173738', 's410765896'] | [53960.0, 54044.0] | [457.0, 475.0] | [481, 475] |
p02630 | u617953889 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['#D more faster method than above see it ..........\nl = lambda : list(map(int,input().split().strip()))\nn = int(input())\na = l\nt = [0]*(10**5+1)\ns = 0\nfor i in a:\n s += i\n t[i] += 1\nq = int(input())\nfor _ in range(q):\n b,c = l\n s += (c-b)*t[b]\n t[c] += t[b]\n ... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s467373278', 's783281467', 's517940461'] | [9548.0, 89628.0, 20732.0] | [33.0, 2345.0, 523.0] | [328, 408, 332] |
p02630 | u618363477 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\nfor i in range(Q):\n B, C = map(int, input().split())\n for i in range(N):\n if A[i] == B:\n A[i] = C\n print(sum(A))\n', 'from collections import Counter\n \nn = int(input())\na = list(map(int, input().split()... | ['Wrong Answer', 'Accepted'] | ['s833029611', 's771478424'] | [20836.0, 24016.0] | [2206.0, 591.0] | [218, 266] |
p02630 | u618532828 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int,input().split()))\nQ = int(input())\nB=[]\nC=[]\n\nfor _ in range(q):\n bi, ci = list(map(int, input().split()))\n B.append(bi)\n C.append(ci)\n\ndic = {}\nfor i in A:\n dic[i] = dic.get(i,0) + 1\n\nsum = sum(A)\n\nfor i in range(Q):\n sum += dic[B[i]] * (C[i] -B[i])\... | ['Runtime Error', 'Accepted'] | ['s148714632', 's917447007'] | [20960.0, 29788.0] | [49.0, 404.0] | [359, 424] |
p02630 | u629350026 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\ntemp=sum(a)\nimport collections\nca=collections.Counter(a)\nprint(ca)\nfor i in range(q):\n b,c=map(int,input().split())\n ba=ca[b]\n temp=temp-b*ba+c*ba\n ca[b]=ca[b]-ba\n ca[c]=ca[c]+ba\n', 'n=int(input())\na=list(map(int,input().split()))\nq=in... | ['Wrong Answer', 'Accepted'] | ['s588779164', 's898668935'] | [25260.0, 24024.0] | [344.0, 591.0] | [247, 251] |
p02630 | u633203155 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["import collections\n\ndef calc_sum(c):\n sum_val = 0\n for key, val in c.items():\n sum_val += key * val\n return sum_val\n\nN = int(input())\narr = list(map(int, input().split()))\nQ = int(input())\n\nactions = []\n\nfor i in range(Q):\n B, C = map(int, input().split())\n actions.append({'B':B,... | ['Wrong Answer', 'Accepted'] | ['s294168996', 's077960755'] | [50160.0, 50144.0] | [417.0, 419.0] | [542, 542] |
p02630 | u638456847 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N = int(readline())\n A = [int(i) for i in readline().split()]\n\n d = dict()\n for a in A:\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\n\n total = sum(... | ['Wrong Answer', 'Accepted'] | ['s484263595', 's755938507'] | [147480.0, 26624.0] | [3597.0, 177.0] | [740, 736] |
p02630 | u647087591 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n\nl = {}\nans = []\nfor e in a:\n l[e] = l[e] + 1 if l.get(e) else 1\n\nsum = 0\nfor k, v in l.items():\n sum += k * v\n\nfor _ in range(q):\n b, c = map(int, input().split())\n if b in l:\n sum += (c - b) * l[b]\n ans.appe... | ['Wrong Answer', 'Accepted'] | ['s533286505', 's286683585'] | [21020.0, 20840.0] | [311.0, 476.0] | [340, 250] |
p02630 | u653931433 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\nB = []\nC = []\n \nfor _ in range(Q):\n b, c = map(int, input().split())\n B.append(b)\n C.append(c)\n \nS = sum(A)\nmemory = [0] * 100001\nfor num in A:\n memory[num] += 1\nfor i in range(Q):\n S = S + memory[B[i]] * (C[i]- B[i])\n... | ['Wrong Answer', 'Accepted'] | ['s855017473', 's218150234'] | [22260.0, 22080.0] | [326.0, 314.0] | [362, 366] |
p02630 | u655048024 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\na = list(map(int,input()))\nq = int(input())\nfor i in range(q):\n summ = 0\n b,c = map(int,input().split())\n for i in range(N):\n if(a[i]==b):\n a[i] = c\n summ += a[i]\n print(summ)\n', 'N = int(input())\na = list(map(int,input().split()))\nq = int(input())\nnum = []\nsumm = 0\nfor... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s125085095', 's420673665', 's869699229', 's014444958'] | [10600.0, 20896.0, 21128.0, 20940.0] | [441.0, 518.0, 556.0, 510.0] | [208, 297, 300, 308] |
p02630 | u657786757 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import sys\nimport numpy as np\nimport math \nimport collections\nfrom collections import deque\nfrom collections import defaultdict\nfrom copy import deepcopy\nfrom itertools import accumulate \ndef input(): return sys.stdin.readline().rstrip()\nfrom functools import lru_cache \n\ndef main():\n n = int(sys.stdin... | ['Wrong Answer', 'Accepted'] | ['s035006862', 's521573743'] | [60444.0, 55036.0] | [2207.0, 352.0] | [1002, 1076] |
p02630 | u658915215 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N=int(input())\nA=list(map(int,input().split()))\nQ=int(input())\n\nbase=sum(A)\n\nfrom collections import Counter\n\nad=Counter(A)\n\nfor _ in range(Q):\n b,c=map(int.input().split())\n if ad[b]!=0:\n base+=(c-b)*ad[b]\n ad[c]+=ad[b]\n ad[b]=0\n print(base)', 'from collections import Co... | ['Runtime Error', 'Accepted'] | ['s333006222', 's141926884'] | [20864.0, 21396.0] | [60.0, 573.0] | [272, 334] |
p02630 | u662430503 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['def main():\n n = int(input())\n a = list(map(int,input().split()))\n q = int(input())\n for _ in range(q):\n b, c = map(int, input().split())\n sum=0\n for i in range(0,n):\n if(a[i]==b):\n a[i]=c\n sum+=a[i]\n print(sum)\nmain()', 'import collections\ndef main():\n n = int(input(... | ['Wrong Answer', 'Accepted'] | ['s354814645', 's103918117'] | [20540.0, 24004.0] | [2206.0, 541.0] | [253, 308] |
p02630 | u664015993 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nd = dict()\ns = 0\nfor num in a:\n if num in d:\n d[num] += 1\n else:\n d[num] = 1\n s += num\nfor i in range(q):\n B, C = list(map(int, input().split()))\n if B in d:\n if C in d:\n d[C] += d[B]\n else:\n d[C] = d[B]\... | ['Runtime Error', 'Accepted'] | ['s897426329', 's840812421'] | [20580.0, 20956.0] | [73.0, 522.0] | [344, 328] |
p02630 | u674588203 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\n\nN=int(input())\nA=list(map(int,input().split()))\nc=Counter(A)\ncommons=c.most_common()\n\nans=0\n\ndic={}\nfor common in commons:\n dic[common[0]]=common[1]\n ans+=common[0]*common[1]\n# print(dic)\n# print(ans)\n\nQ=int(input())\nfor i in range(Q):\n b,c=map(int,input().s... | ['Runtime Error', 'Accepted'] | ['s178305841', 's536007772'] | [25160.0, 25404.0] | [87.0, 553.0] | [394, 602] |
p02630 | u686036872 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\n\nN = int(input())\n\nA = list(map(int, input().split()))\nc = Counter(A)\nS = sum(A)\n\nQ = int(input())\nfor _ in range(Q):\n x, y = map(int, input().split())\n S += (c[x]*(y-x))\n print(S)\n c[y] = c[x]\n c[x] = 0', 'from collections import Counter\n\nN = int(input()... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s427593900', 's525685491', 's073971231'] | [23940.0, 21444.0, 23936.0] | [569.0, 480.0, 553.0] | [250, 221, 251] |
p02630 | u686174642 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\narr=[int(i) for i in input().strip().split(" ")]\nt=int(input())\ndic={}\nsum_array=0\nfor i in arr:\n dic[i]=dic.get(i,0)+1\n sum_array+=i\n \n\nfor _ in range(t):\n a,b=[int(i) for i in input().split(" ")]\n if b in dic:\n dic[b]+=dic[a]\n else:\n dic[b]=dic[a]\n \... | ['Runtime Error', 'Accepted'] | ['s062262697', 's619975814'] | [20892.0, 21124.0] | [557.0, 544.0] | [367, 426] |
p02630 | u687553041 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["import sys\n\nif __name__ == '__main__':\n n = int(sys.stdin.readline().rstrip())\n A = list(map(lambda x: int(x), sys.stdin.readline().split()))\n q = int(sys.stdin.readline().rstrip())\n B, C = [], []\n for i in range(q):\n b, c = list(map(lambda x: int(x), sys.stdin.readline().split()))\n ... | ['Wrong Answer', 'Accepted'] | ['s265964134', 's048872305'] | [22088.0, 40768.0] | [2206.0, 428.0] | [526, 685] |
p02630 | u692054751 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\nN = int(input())\nA = [int(s) for s in input().split()]\nQ = int(input())\n\nd = Counter(A)\ntotal = sum(A)\n\nfor _ in range(Q):\n b, c = [int(s) for s in input().split()]\n if d[b]:\n total += (c - b) * d[b]\n d[c] = d[b]\n d[b] = 0\n print(total)\n\n',... | ['Wrong Answer', 'Accepted'] | ['s169616959', 's862721079'] | [21476.0, 21472.0] | [524.0, 531.0] | [300, 324] |
p02630 | u693025087 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['# -*- coding: utf-8 -*-\nimport collections\nN = int(input())\nA = list(map(int, input().split()))\nA_amount = collections.Counter(A)\n\nresult = sum(A)\n\nQ = int(input())\nfor q in range(Q):\n B, C = map(int, input().split())\n\tB_elem = A_amount.get(B, None)\n if B_elem is not None:\n C_elem = A_amoun... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s087422022', 's156106157', 's270675484', 's645342132', 's568624308'] | [8800.0, 9052.0, 21260.0, 147816.0, 21256.0] | [29.0, 25.0, 54.0, 2459.0, 519.0] | [583, 583, 2570, 572, 552] |
p02630 | u693716675 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = [int(i) for i in input().split()]\nq = int(input())\n\nans = sum(a)\nnumbers = [0]*(10**5+1)\nfor _ in range(q):\n b,c = [int(i) for i in input().split()]\n nb = numbers[b]\n ans += (c-b)*nb\n print(ans)\n numbers[b] = 0\n numbers[c] += nb ', 'n = int(input())\na = [int(i) f... | ['Wrong Answer', 'Accepted'] | ['s390349565', 's779090442'] | [20384.0, 20960.0] | [484.0, 497.0] | [271, 304] |
p02630 | u696444274 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\n# w = list(map(int, input().split()))\n\na = list(map(int, input().split()))\n\nq = int(input())\n#p = list(map(int, input().split()))\n#a = list(map(int, input().split()))\n\nbc = [list(map(int, input().split())) for i in range(q)]\n# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))\na_coun... | ['Runtime Error', 'Accepted'] | ['s457938247', 's843659915'] | [31372.0, 43236.0] | [229.0, 373.0] | [784, 803] |
p02630 | u696684809 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import math\n\nn = int(input())\na = [0]*10**7\nx = math.sqrt(10)\nb = math.floor(x)\nl = 0\nfor i in range(1,n+1):\n x = math.sqrt(i)\n b = math.floor(x)\n for j in range(1,b+1):\n if(i%j==0 and i//j == j):\n a[i-1] +=1\n elif(i%j==0):\n a[i-1] +=2\nfor k in range(n):\n l = l + a[k]*(k+1)\nprint(... | ['Wrong Answer', 'Accepted'] | ['s284861014', 's405653547'] | [87236.0, 22232.0] | [2208.0, 344.0] | [306, 336] |
p02630 | u698919163 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int,input().split()))\n\nnum_count = [0]*(10**5+1)\ntmp_sum = sum(A)\nfor i in A:\n num_count[i] += 1\n\nfor q in range(int(input()):\n B,C = map(int,input().split())\n gain = C*(num_count[B])\n loss = B*(num_count[B])\n num_count[C] += num_count[B]\n num_count[B] = 0\... | ['Runtime Error', 'Accepted'] | ['s973811241', 's438796316'] | [8888.0, 20948.0] | [22.0, 494.0] | [360, 361] |
p02630 | u698977701 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\narr = list(map(int, input().split()))\n\nsu = sum(arr)\n\nq = int(input())\nfor i in range(q):\n\tb,c = map(int, input().split())\n si = su -b + c\n print(si)\n', 'def ad(a,bank):\n\tif a not in bank:\n\t\tbank[a] = 1\n\telse:\n\t\tbank[a] += 1\n\ndef rp(a,b,bank):\n\tans = 0\n\tif a in bank:\... | ['Runtime Error', 'Accepted'] | ['s827917664', 's988910755'] | [8968.0, 20860.0] | [22.0, 546.0] | [173, 503] |
p02630 | u703823201 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['mport sys\nN = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\n\n\nfor q in range(Q):\n b, c = map(int, input().split())\n for n in range(N):\n if b == A[n]:\n A[n] = c\n print(sum(A))', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\ncnt = c... | ['Runtime Error', 'Accepted'] | ['s046286485', 's779646092'] | [9012.0, 21400.0] | [26.0, 563.0] | [221, 299] |
p02630 | u706414019 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | [' = int(input())\nA = list(map(int,(input().split())))\nQ = int(input())\nnum_list = [0]*(N+1)\ns = []\nfor i in range(N):\n num_list[A[i]] += 1\nfor _ in range(Q):\n s_s = 0\n B,C = map(int,(input().split()))\n num_list[C] += num_list[B]\n num_list[B] = 0\n for j in range(N+1):\n s_s += (j)*n... | ['Runtime Error', 'Accepted'] | ['s844558609', 's239818821'] | [8900.0, 24128.0] | [27.0, 281.0] | [369, 404] |
p02630 | u718949306 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nC = sum(A)\nZ = {}\nfor n in range(N):\n Z[A[n]] = 0\nfor n in range(N):\n Z[A[n]] += 1\nD = []\nQ = int(input())\nfor q in range(Q):\n x, y = map(int, input().split())\n if x in Z:\n C = C - x*Z[x]\n C = C + y*Z[x]\n D.append(C)\... | ['Wrong Answer', 'Accepted'] | ['s648156291', 's544362290'] | [21828.0, 21668.0] | [329.0, 333.0] | [437, 459] |
p02630 | u723792785 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import collections\nimport random\ninp = list(range(1, 100001))\ndic = dict(collections.Counter(inp))\nwa = 0\nfor i, j in dic.items():\n\twa += i * j\nse = set(dic.keys())\nfor i in range(int(input())):\n\ta = random.randrange(1, 10001)\n\tb = random.randrange(1, 10001)\n\tif a in se:\n\t\twa += dic[a] * (b-a)\n\t\t... | ['Wrong Answer', 'Accepted'] | ['s778637774', 's832386181'] | [25632.0, 23488.0] | [312.0, 523.0] | [393, 373] |
p02630 | u730449065 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\n\nl = list(map(int, input().split()))\n\nsort(l)\n\nm = int(input())\n\nfor i in range(m):\n a,b = map(int, input().split())\n \n l = [b if j == a else j for j in l]\n\n print(sum(l))', '#from collections import defaultdict\n\nn = int(input())\ncnt =[0]*1000000\n\nl = list(map(int, input... | ['Runtime Error', 'Accepted'] | ['s211453281', 's355577834'] | [20824.0, 28636.0] | [42.0, 508.0] | [200, 337] |
p02630 | u751277549 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\n\n\nN = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\n\nsumA = sum(A)\ncnt_num = np.zeros(10**5 + 1)\n\nfor i in A:\n cnt_num[i] += 1\n\nfor i in range(Q):\n B, C = map(int, input().split())\n sumA += (C - B) * cnt_num[B]\n print(sumA)\n cnt_num[C] += cnt_num[... | ['Wrong Answer', 'Accepted'] | ['s429225450', 's937402815'] | [38392.0, 38740.0] | [734.0, 724.0] | [322, 332] |
p02630 | u756609156 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\nm = {}\ntot = 0\nfor a in map(int,input().split()):\n tot += m\n if a not in m:\n m[a]=0\n m[a] += 1\nq = int(input())\nfor step in range(q):\n b,c = map(int,input().split())\n if c not in m:\n m[c] = 0\n if b in m:\n m[c] += m[b]\n tot += m[b]*(c-b)\n m[b] = 0\n print(tot)\n\n... | ['Runtime Error', 'Accepted'] | ['s822540892', 's789964303'] | [17048.0, 21832.0] | [35.0, 559.0] | [299, 297] |
p02630 | u763534217 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nb = []\nc = []\nfor i in range(q):\n _ = list(map(int, input().split()))\n c.append(_[1])\n b.append(_[0])\n\ns = sum(a)\n\n\nhist = {}\nfor i in range(n):\n if a[i] in hist:\n hist[a[i]] += 1\n else:\n hist[a[i]] = ... | ['Wrong Answer', 'Accepted'] | ['s701129220', 's598241200'] | [89852.0, 26880.0] | [2348.0, 368.0] | [637, 666] |
p02630 | u763550415 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\n\nfor _ in range(Q):\n B, C = map(int, input().split())\n count = A.count(B)\n if count >0:\n A.remove(B)\n A.extend([C]*count)\n print(sum(A))', 'N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\ncnt = [0]*(10**... | ['Wrong Answer', 'Accepted'] | ['s162792026', 's140836161'] | [219764.0, 20868.0] | [2211.0, 484.0] | [216, 245] |
p02630 | u766566560 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['# ans\n\nN = int(input())\nA = list(map(int, input().split()))\ncnt = [0] * 100000\nfor i in range(A):\n cnt[i] += 1\nQ = int(input())\nS = sum(A)\n\nfor i in range(Q):\n B, C = map(int, input().split())\n diff = (C - B) * cnt[B]\n S += diff\n print(S)\n cnt[C] += cnt[B]\n cnt[B] = 0', '# ans\n\nN = int(input(... | ['Runtime Error', 'Accepted'] | ['s848048229', 's293916582'] | [20916.0, 20880.0] | [51.0, 496.0] | [275, 268] |
p02630 | u779293207 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["H,W,K=map(int,input().split())\nc=[list(input()) for i in range(H)]\nb=0\nfor i in range(H):\n b+=c[i].count('#')\nif b==K:\n print(1)\n exit()\n \nelse:\n a=K-b\n count=0\n hc=[]\n wc=[]\n for i in range(2 ** H):\n h=['0']*H \n for j in range(H):\n if ((i >> j) & 1):\n h[H- 1 - j] = ... | ['Runtime Error', 'Accepted'] | ['s526231979', 's640979628'] | [9304.0, 24012.0] | [23.0, 547.0] | [874, 264] |
p02630 | u788608806 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['\n\nN = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\nnizi = [0] * (max(A)+1)\nfor i in range(len(A)):\n print(A[i], A)\n nizi[A[i]] += 1\nsumall = sum(A)\nfor q in range(Q):\n B, C = map(int, input().split())\n sumall += (C-B) * nizi[B]\n nizi[C] =+ nizi[B]\n nizi[B] = 0\n ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s092582411', 's448793420', 's764671157', 's788455093'] | [145816.0, 20964.0, 21200.0, 21068.0] | [2364.0, 488.0, 484.0, 510.0] | [317, 319, 316, 336] |
p02630 | u790905630 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['def main():\n N = int(input())\n A = input()\n Q = input()\n\n answer = sum(list(map(int, A.split())))\n A = A.replace(" ", "")\n\n operateList = (open(0).read().split("\\n"))[:-1]\n\n for operate in operateList:\n B, C = operate.split()\n numB = A.count(B)\n\n answer = answe... | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s106703621', 's178900291', 's274982217', 's321032857', 's399022993'] | [32864.0, 32752.0, 32864.0, 20820.0, 20860.0] | [2207.0, 2207.0, 2207.0, 444.0, 207.0] | [421, 444, 488, 444, 551] |
p02630 | u798093965 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int,input().split()))\nq = int(input())\nb = [0] * q\nc = [0] * q\nans = sum(a)\nnumber = [0] * 100000\nfor i in range(q):\n b[i],c[i] = map(int,input().split())\nfor i in range(n):\n number[a[i]] += 1\nfor i in range(q):\n if number[b[i]] > 0:\n ans += (c[i] - b[i]) * n... | ['Runtime Error', 'Accepted'] | ['s328323791', 's953622881'] | [22108.0, 21948.0] | [247.0, 290.0] | [396, 399] |
p02630 | u800058906 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\nbc=[list(map(int,input().split())) for i in range(q)]\n\nasum=sum(a) \nd={}\n\nfor i in a:\n if i in d:\n d[i]+=1\n else:\n d[i]=1\n\nfor b,c in bc:\n print(b)\n print(c)\n if b in d:\n asum+=d[b]*(c-b)\n if c in d:\n d[c]+=d[b]\n... | ['Wrong Answer', 'Accepted'] | ['s474697469', 's787743261'] | [35720.0, 35828.0] | [412.0, 358.0] | [379, 357] |
p02630 | u806976856 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\nnum=[0]*(10**5+1)\nans=sum(a)\nfor i in a:\n num[i]+=1\nfor i in range(q):\n b,c=map(int,input().split())\n ans=ans+(c-b)*num[b-1][0]\n num[c-1][0]+=num[b-1][0]\n num[b-1][0]=0\n print(ans)\n ', 'n=int(input())\na=list(map(int,inpu... | ['Runtime Error', 'Accepted'] | ['s305956686', 's725559838'] | [20888.0, 20968.0] | [64.0, 489.0] | [266, 251] |
p02630 | u809714729 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import collections\nN = int(input())\nA = list(map(int, input().split()))\nindices = collections.defaultdict(list)\nfor i, a in enumerate(A):\n indices[a].append(i)\nQ = int(input())\nfor _ in range(Q):\n B, C = map(int, input().split())\n print(B, C)\n for i in indices[B]:\n indices[C].append(i)\n A[i] = C... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s116397815', 's637997957', 's464276560'] | [139844.0, 9016.0, 23852.0] | [2210.0, 25.0, 532.0] | [322, 272, 323] |
p02630 | u811817592 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\ndic={}\nfor i in range(len(a)):\n dic.setdefault(a[i],1)\n dic[a[i]]+=1\nanswer=sum(a)\nfor i in range(q):\n b,c=map(int,input().split())\n dic.setdefault(b,0)\n dic.setdefault(c,dic[b])\n dic[c]+=dic[b]\n answer=answer+dic[b]*c-dic[b]... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s070350609', 's337050603', 's678804862', 's780798440', 's841695920', 's611041890'] | [88424.0, 10792.0, 10708.0, 23624.0, 23508.0, 23876.0] | [2669.0, 29.0, 28.0, 564.0, 567.0, 573.0] | [325, 320, 320, 339, 340, 448] |
p02630 | u815878613 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\n\nimport sys\n\nreadline = sys.stdin.buffer.readline\n\ndef solver(int N, list A, int Q, list BC):\n d = Counter(A)\n\n sub_s = sum(A)\n\n for b, c in BC:\n sub_s += d[b] * (c - b)\n d[c] += d[b]\n d[b] = 0\n\n print(sub_s)\n\n\ndef run():\n N =... | ['Runtime Error', 'Accepted'] | ['s842188111', 's178639204'] | [8840.0, 34688.0] | [29.0, 245.0] | [479, 394] |
p02630 | u823885866 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import sys\nimport collections\n\nri = lambda: int(sys.stdin.readline())\nrm = lambda: map(int, sys.stdin.buffer.readline().split())\nrl = lambda: list(map(int, sys.stdin.readline().split()))\n\nn = ri()\na = rl()\nil = list(set(a))\nli = collections.Counter(a)\nq = ri()\nres = []\nbc = [rm() for _ in range(q)]\nfor ... | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s097255856', 's270924542', 's406328462', 's883449196'] | [58492.0, 21240.0, 21160.0, 20172.0] | [2207.0, 2206.0, 2206.0, 206.0] | [608, 583, 538, 371] |
p02630 | u826785572 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nq = int(input())\n\nans = sum(a)\nA = Counter(a).most_common()\nd = [0] * 10**5+10\nfor i in range(len(A)):\n d[A[i][0]] = A[i][1]\n\nB = []\nC = []\nfor i in range(q):\n b, c = map(int, input().split())\n B.append(b)\n ... | ['Runtime Error', 'Accepted'] | ['s533941462', 's518534744'] | [21236.0, 27696.0] | [89.0, 370.0] | [434, 436] |
p02630 | u830054172 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nsumA = sum(A)\n\ndic = Counter(A)\n\nQ = int(input())\n\nfor _ in range(Q):\n b, c = map(int, input().split())\n if b in dic.keys():\n ans = sumA+(dic[b]*(c-b))\n\n B = dic[b]\n if c in dic.keys():\n ... | ['Runtime Error', 'Accepted'] | ['s428690393', 's618819284'] | [21464.0, 21292.0] | [576.0, 483.0] | [500, 371] |
p02630 | u833238721 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nS = sum(A)\nL = [0] * 100001\nfor i in A:\n L[i] += 1\nQ = int(input())\nfor i in range(Q):\n B, C = map(int, input().split())\n S += (C - B) * L[B]\n L[C] += Ct[B]\n L[B] = 0\n print(S)', 'N = int(input())\nA = list(map(int, input().split()))\n... | ['Runtime Error', 'Accepted'] | ['s447750960', 's913659896'] | [20992.0, 20684.0] | [58.0, 459.0] | [247, 246] |
p02630 | u833738197 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["import numpy as np\nn = int(input())\nA = list(map(int,input().split()))\nq = int(input())\nBC = [list(map(int,input().split())) for _ in range(q)]\nA = np.array(A)\n \ndef main(A,BC):\n for bc in BC:\n A = np.where(A==bc[0],bc[1],A)\n print(max(A))\n \nif __name__ == '__main__':\n main(A,B... | ['Wrong Answer', 'Accepted'] | ['s023039085', 's092120221'] | [49740.0, 114164.0] | [2207.0, 836.0] | [307, 432] |
p02630 | u842033632 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['\nimport numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\nQ = int(input())\nu, count = np.unique(A,return_counts=True)\nasum = A.sum()\nfor i in range(Q):\n B, C = list(map(int, input().split()))\n if B in u:\n posB = np.where(u==B)\n asum += int(count[posB]) * (C-B)\n... | ['Wrong Answer', 'Accepted'] | ['s665524812', 's141491861'] | [38888.0, 38660.0] | [2218.0, 781.0] | [617, 382] |
p02630 | u849341325 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import bisect\n\nN = int(input())\nA = list(map(int,input().split()))\n\nQ = int(input())\n\nA.sort()\nB = list(set(A))\nX = [[0 for j in range(2)] for i in range(len(B))]\nfor i in range(len(B)):\n b=bisect.bisect_left(A,B[i])\n c=bisect.bisect_right(A,B[i])\n num = c - b \n X[i][0] = B[i]\n X[i][1] = num\n\nM ... | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s411172054', 's426669450', 's483498834', 's517091886', 's614442758'] | [27844.0, 9052.0, 40156.0, 69712.0, 73440.0] | [2206.0, 24.0, 296.0, 382.0, 532.0] | [836, 774, 391, 374, 374] |
p02630 | u856819253 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import sys\n\ndef L(): return sys.stdin.readline().rstrip()\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI():return list(map(int,sys.stdin.readline().rstrip().split()))\ndef LS():return list(sys.stdin.readline().rstrip().split())\n\nimport re\ndef solver(N,A,Q,BC):\n\n for b,c in BC:\n #print(A... | ['Wrong Answer', 'Accepted'] | ['s315636313', 's400070715'] | [48048.0, 40440.0] | [2242.0, 285.0] | [781, 665] |
p02630 | u857657465 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())+1\na = list(map(int, input().split()))\ncnt = []\n\nfor i in range(100005):\n cnt.append(0)\nsum = 0\nfor i in range(n):\n cnt[i] = a.count(i)\n sum += i * cnt[i]\n\nq = int(input())\nans = []\n\nfor i in range(q):\n b, c = map(int, input().split())\n sum += (c-b)*cnt[b]\n cnt[c] +=... | ['Wrong Answer', 'Accepted'] | ['s959376350', 's430337006'] | [20860.0, 20608.0] | [2206.0, 307.0] | [343, 474] |
p02630 | u860002137 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["from collections import defaultdict\nfrom collections import Counter\nfrom numba import jit\n\nn = int(input())\na = list(map(int, input().split()))\narr = defaultdict(int)\nq = int(input())\nbc = []\nfor _ in range(q):\n b, c = map(int, input().split())\n bc.append((b, c))\n\n\n@jit('void(i8, i8[:], i8[:], i8,... | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s506051459', 's678512503', 's753081502', 's506457043'] | [136336.0, 126728.0, 136564.0, 36052.0] | [1254.0, 1748.0, 1190.0, 414.0] | [562, 536, 525, 454] |
p02630 | u864202285 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\nQ = int(input())\n\ndata = [0] * 100001\n\ndef my_sum(d):\n retval = 0\n\n for i in range(len(d)):\n if d[i] == 0:\n continue\n retval += d[i] * i\n return retval\n\nfor i in A:\n data[i] += 1\n\nsum_val = my_sum(data)\n\nfor ... | ['Wrong Answer', 'Accepted'] | ['s156185207', 's719800149'] | [20752.0, 20804.0] | [488.0, 489.0] | [476, 464] |
p02630 | u867069435 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\n\nn = int(input())\ncount = Counter(input().split())\nans = 0\nfor v, c in count.items():\n ans += int(v) * c\nfor i in range(int(input())):\n b, c = input().split()\n if b in count:\n ans -= count.get(b, 0) * int(b)\n count[c] = count[b] + count.get(c, 0)\n ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s303737846', 's929784409', 's526585918'] | [20388.0, 20520.0, 20620.0] | [535.0, 252.0, 556.0] | [377, 293, 417] |
p02630 | u883040023 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int,input().split()))\nans = sum(a)\n\nimport collections\ncca = collections.Counter(a)\n\nfor i in range(int(input())):\n b,c = map(int,input().split())\n num = cca[b]\n cca[b] = 0\n cca[c] += num \n \n print(ans - num*(b-c))', 'n = int(input())\na = list(map(int,inpu... | ['Wrong Answer', 'Accepted'] | ['s032219823', 's054193531'] | [23968.0, 24156.0] | [568.0, 569.0] | [262, 271] |
p02630 | u886310677 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['#include <bits/stdc++.h>\n\nusing namespace std;\n\n#define F first\n#define S second\n\n\n#define all(c) c.begin(), c.end()\n#define rall(c) c.end(), c.begin()\n#define INF (int)1e9\n#define MOD 1000000007\ntypedef long long ll;\ntypedef vector<int> vi;\ntypedef pair<int, int> pi;\ntypedef map<int, int> MPII;\ntyped... | ['Runtime Error', 'Accepted'] | ['s950867203', 's832924020'] | [8932.0, 24012.0] | [24.0, 590.0] | [1099, 308] |
p02630 | u891516200 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\nimport copy\n\nN = int(input())\n\ntarget_list = map(int, input().split())\ntrans_list = {}\n\nfor i in range(int(input())):\n trans_list[i] = list(map(int, input().split()))\n\ncheck = []\ncheck.append(Counter(target_list))\nanswer = []\n\nfor index, trans in trans_list.items():\n... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s186771128', 's474149436', 's570040014'] | [145932.0, 129260.0, 21440.0] | [2211.0, 2389.0, 553.0] | [707, 481, 442] |
p02630 | u898967808 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n =int(input())\nA = list(map(int,input().split()))\nq = int(input())\n\nfrom collections import defaultdict\ndic = defaultdict(int)\nfor a in A:\n dic[a] += 1 \n \nans = sum(A)\nfor i in range(q): \n b,c = map(int,input().split())\n dic[c] += dic[b]\n diff = dic[c]*c-dic[b]*b\n ans += diff\n print(ans) \n ... | ['Wrong Answer', 'Accepted'] | ['s638529518', 's738087346'] | [24000.0, 23844.0] | [566.0, 557.0] | [316, 319] |
p02630 | u900968659 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['# -*- coding: utf-8 -*-\nn=int(input())\nnumlista=list(map(int,input().split()))\n\nstra=str()\nfor i in numlista:\n stra+=str(i)\n\nsuma=0\nfor i in range(n):\n suma+=numlista[i]\n#\nq=int(input())\nfor i in range(q):\n b,c=map(int,input().split())\n k=c-b\n o=stra.count(str(b))\n suma+=k*o\n print(suma)', '#... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s699072619', 's950931196', 's029901326'] | [20836.0, 17104.0, 23784.0] | [2206.0, 36.0, 549.0] | [341, 245, 384] |
p02630 | u901144784 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\nl=[int(i) for i in input().split()]\ns=sum(l)\nd={}\nfor i in range(n):\n if(l[i] in d):\n d[i]+=1\n else:\n d[i]=1\nq=int(input())\nfor w in range(q):\n b,c=(int(i) for i in input().split())\n if(b in d):\n s-=((d[b]*b)+(d[b]*c))\n d[c]=d[b]\n d[b]=0\n print(s)', 'n=int(input())\n... | ['Runtime Error', 'Accepted'] | ['s340243090', 's108704108'] | [20648.0, 21288.0] | [440.0, 542.0] | [282, 342] |
p02630 | u907403674 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import collections\nn = int(input())\nl = list(map(int, input().split()))\na = int(input())\nc = collections.Counter(l)\nanswer = sum(l)\nfor i in range(a):\n j,k = map(int, input().split())\n save = c[j]\n del c[j]\n c[k] += save\n answer = answer + c[k] -save\n print(answer)\n', 'import collectio... | ['Wrong Answer', 'Accepted'] | ['s089776082', 's052474223'] | [23980.0, 24044.0] | [585.0, 584.0] | [285, 290] |
p02630 | u907865484 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int,input().split()))\nQ = int(input())\n\ncnt_dict = {}\n\n\ns = sum(A)\n\nans = 0\n\nfor item in A:\n if item not in cnt_dict:\n cnt_dict[item] = 0\n cnt_dict[item] += 1\n\nfor _ in range(Q):\n X,Y = map(int,input().split())\n\n if X not in cnt_dict:\n cnt_di... | ['Wrong Answer', 'Accepted'] | ['s324076737', 's385969236'] | [23204.0, 23180.0] | [563.0, 544.0] | [798, 799] |
p02630 | u910426639 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N = int(input())\nA = list(map(int, input().split()))\n\nQ = int(input())\n\ns = sum(A)\n\nfor i in range(Q):\n b, c = map(int, input().split())\n diff = c - A[b - 1]\n A[b - 1] = c\n diff\n print(s)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nQ = int(input())\n\ns = sum(A)\n\nfor i ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s811581526', 's878706016', 's567668613'] | [8836.0, 20864.0, 20808.0] | [26.0, 482.0, 482.0] | [204, 208, 295] |
p02630 | u916205307 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['x = int(input())\nar = list(map(int, input().split()))\nsum_val = sum(ar)\n\nunique_val = dict()\n\nfor i in ar:\n if i in unique_val:\n unique_val[i] += 1\n else:\n unique_val[i] = 1\n\nq = int(input())\nwhile(q):\n a, b = map(int, input().split())\n if a in unique_val:\n value = (b-... | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s540897360', 's789134959', 's074367463'] | [21008.0, 147500.0, 20920.0] | [509.0, 2154.0, 520.0] | [445, 574, 564] |
p02630 | u923662841 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['\n\ndef main():\n n, *i = map(int, open(0).read().split())\n a = i[:n]\u3000\u3000#数列Aのリスト\n _ = i[n]\u3000\u3000\u3000#Qのこと\n s = sum(a)\u3000\u3000#数列Aの総和\n\n m = [0] * (10 ** 5 + 1)\u3000\u3000#Aは1<A<10^5なのでラベル用リストを作成\n for x in a:\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000#Aの個数をラベル化。リ... | ['Runtime Error', 'Accepted'] | ['s120799947', 's132265373'] | [8804.0, 44004.0] | [23.0, 147.0] | [861, 384] |
p02630 | u932868243 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\nnuml=[0 for i in range(10**5+1)]\ns=sum(a)\nfor aa in a:\n numl[aa-1]+=1\n\nfor qq in range(q):\n x,y=map(int,input().split())\n s+=numl[x-1]*(y-x)\n print(s)\n numl[y-1]+=numl[x-1]\n numl[x-1]=0\n print(numl)', 'import collections\nn=int(input(... | ['Wrong Answer', 'Accepted'] | ['s954523176', 's410813352'] | [144016.0, 23992.0] | [2382.0, 582.0] | [268, 233] |
p02630 | u934119021 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n dic[a[i]] += 1\nq = int(input())\nans = [sum(a)]\nfor i in range(q):\n b, c = map(int, input().split())\n ans.append(ans[-1] + (c - b) * dic[b])\n dic[c] += dic[b]\n dic[b] = 0\nfor i in range(1, q + 1):\n print(ans[i])', 'k = [i for i ... | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s642420695', 's953508504', 's485606512'] | [20896.0, 30704.0, 30664.0] | [48.0, 661.0, 370.0] | [289, 434, 391] |
p02630 | u944325914 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na=list(map(int,input().split()))\nq=int(input())\nfor i in range(q):\n b,c = map(int,input().split())\n a=[c if i==b else i for i in a]\n print(a)\n print(sum(a))', 'from collections import Counter\nn=input()\na=list(map(int,input().split()))\nb=Counter(a)\nn=int(input())\nans=sum(a)\nfor i in ran... | ['Wrong Answer', 'Accepted'] | ['s836944865', 's823373927'] | [145628.0, 24140.0] | [3533.0, 572.0] | [175, 226] |
p02630 | u944886577 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n=int(input())\na_list=list(map(int,input().split()))\ncnt = [0] * int(1e5 + 10)\nsum=0\nfor i in a_list:\n cnt[i] +=1\n sum+=i\n \nq=int(input())\nans=0\n \nfor j in range(q):\n x,y=map(int,input().split())\n sum+=(y-x)*cnt[x]\n cnt[x]+=cnt[y]\n cnt[y]=0\n print(sum)', 'n=int(input())\ns=[]\ns=input().split()\nq=in... | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s017448841', 's040894262', 's100654756', 's154309261', 's329950624', 's465524167', 's466969409', 's663210348', 's679934959', 's802188482', 's805599397', 's806985928', 's808984935', 's900948368', 's966269187', 's497461727'] | [21028.0, 8972.0, 20988.0, 18316.0, 20852.0, 83732.0, 20924.0, 20660.0, 19476.0, 56336.0, 16860.0, 10656.0, 52116.0, 21032.0, 10572.0, 21084.0] | [485.0, 25.0, 505.0, 95.0, 489.0, 2308.0, 487.0, 487.0, 70.0, 597.0, 34.0, 2206.0, 2206.0, 490.0, 2206.0, 490.0] | [253, 165, 253, 201, 253, 243, 250, 227, 221, 240, 168, 195, 195, 253, 197, 253] |
p02630 | u950825280 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ["n = int(input())\na = list(map(int, input().split()))\nq = int(input())\n\ns = ','.join(map(str, a)) + ','\nans = []\n\nfor _ in range(q):\n b, c = map(str, input().split())\n s = s.replace(b+',', c+',')\n ans.append(s)\n \nfor i in ans:\n print(i[:-1])\n print(sum(int(str) for str in i[:-1].split('... | ['Wrong Answer', 'Accepted'] | ['s130001381', 's672429932'] | [795144.0, 22980.0] | [2231.0, 587.0] | [314, 509] |
p02630 | u953379577 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import collections as c\n\nn = int(input())\n\na = list(map(int,input().split()))\n\nq = int(input())\n\ns = sum(a)\n\ncnt = c.Counter(a)\n\nfor i in range(q):\n b,c = map(int,input().split())\n s += (c-b)*cnt[b-1]\n cnt[c-1] += cnt[b-1]\n cnt[b-1] = 0\n print(s)', 'import collections as c\n\nn = int(i... | ['Wrong Answer', 'Accepted'] | ['s407349910', 's674077815'] | [24108.0, 24016.0] | [605.0, 566.0] | [261, 253] |
p02630 | u968404618 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import *\nfrom operator import mul\n\nn = int(input())\nA = list(map(int, input().split()))\nq = int(input())\n\n\nA_dic = Counter(A)\nA_sum = sum(A)\n\nfor _ in range(q):\n b, c = map(int, input().split())\n tmp = A_dic[b]\n A_dic[c] += tmp\n A_dic[b] = 0\n A_sum += c*A_dic[c] - b*tmp... | ['Wrong Answer', 'Accepted'] | ['s569439080', 's781982781'] | [24072.0, 24184.0] | [567.0, 574.0] | [319, 292] |
p02630 | u978313283 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['import numpy as np\nN=int(input())\nA=list(map(int,input().split()))\nSUM=sum(A)\nQ=int(input())\nindex=np.array([i for i in range(10**5+1)])\nList=np.array([0 for _ in range(10**5+1)])\nfor a in A:\n List[a]+=1\nBList=np.array([0 for _ in range(10**5+1)])\nfor q in range(Q):\n B,C=map(int,input().split())\n ... | ['Wrong Answer', 'Accepted'] | ['s122003638', 's296954422'] | [39072.0, 38224.0] | [2206.0, 783.0] | [354, 302] |
p02630 | u981418135 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['n = int(input())\na = list(map(int, input().split()))\nq = int(input())\nsums = sum(a)\nd = {}\n\nfor i in a:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n\nfor i in range(q):\n b,c = map(int, input().split())\n if b in d:\n sums += d[b]*(c-b)\n if c in d:\n d[c] += d[b]\n ... | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s186336065', 's420411480', 's256344058'] | [8988.0, 9124.0, 20620.0] | [28.0, 24.0, 527.0] | [356, 262, 360] |
p02630 | u984592063 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['from collections import Counter\nn = int(input())\na=list(map(int,input().split()))\nq = int(input())\nbc=[list(map(int,input().split())) for _ in range(q)]\n\na_c = Counter(a)\n\n', 'from collections import Counter\nn = int(input())\na=list(map(int,input().split()))\nq = int(input())\nbc=[list(map(int,input().split(... | ['Wrong Answer', 'Accepted'] | ['s831547326', 's731089053'] | [36244.0, 36248.0] | [245.0, 430.0] | [172, 486] |
p02630 | u989074104 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['N=int(input())\nlistA=list(map(int, input().split()))\nQ=int(input())\n\nlistB=[] \nwhile True:\n try:\n listB.append(list(map(int,input().split())))\n\n except:\n break;\n \nsum=sum(listA)\nnumlist=[0]*(10**5+1)\nfor i in range(10**5+1):\n numlist[i]=listA.count(i)\n \nfor i in range(Q):... | ['Wrong Answer', 'Accepted'] | ['s002221058', 's643096600'] | [32484.0, 31900.0] | [2207.0, 334.0] | [478, 489] |
p02630 | u991619971 | 2,000 | 1,048,576 | You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq i \leq Q), find S_{i}: the sum of all elements in A just after the i-th... | ['#import math\n#import numpy as np\n#import torch\n#import torch.nn as nn\n#import matplotlib.pyplot as plt\n#from decimal import Decimal\n#import itertools\nimport collections\n\nN=int(input())\n#N,K = map(int,input().split())\n#B,W = map(int,input().split())\n#T=int(input())\nA = list(map(int,input().split()))\n#S=s... | ['Wrong Answer', 'Accepted'] | ['s847413979', 's891924518'] | [21412.0, 21368.0] | [576.0, 522.0] | [569, 553] |
p02631 | u001769145 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['# ABC171 E \n\nimport itertools\n\nn = int(input())\na_l = [list(format(int(x), "030b")) for x in input().split()]\n\nfor _d,_tp in enumerate(zip(*a_l)):\n if "1" not in _tp:\n continue\n if "0" not in _tp:\n continue\n else:\n _num = _tp.count("0")\n if _num % 2 == 1:\n ... | ['Wrong Answer', 'Accepted'] | ['s459208558', 's734575708'] | [87720.0, 87708.0] | [1817.0, 1612.0] | [502, 500] |
p02631 | u004482945 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ["n = int(input())\na = list(map(int, input().split()))\nans = 0\nans_list = []\nfor i in a:\n s = str(bin(i))\n s = s[2:]\n ans_list.append(int(s))\n ans += int(s)\nz = []\nfor i in ans_list:\n z.append(ans - i)\nf = []\nfor i in z:\n e = []\n for j in str(i):\n if int(j) % 2 == 0:\n j = 0\n if int(j... | ['Wrong Answer', 'Accepted'] | ['s509842121', 's946504198'] | [49140.0, 41768.0] | [2207.0, 140.0] | [417, 136] |
p02631 | u014800961 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['n = int(input())\nalist = list(map(int,input().split()))\n\nfrom itertools import combinations\n \nperm = combinations(alist,len(alist)-1)\n\nans = []\nfor i in perm:\n xor = 0 \n for j in i:\n xor ^= j\n ans.append(xor)\n\nprint(" ".join(str(x) for x in ans))', 'n = int(input())\nalist = list(map(in... | ['Wrong Answer', 'Accepted'] | ['s896427453', 's976036223'] | [31452.0, 41784.0] | [2206.0, 168.0] | [263, 175] |
p02631 | u026155812 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ["N = int(input())\na = [int(i) for i in input().split()]\nans = []\nfor x in a:\n s = '1'*(len(str(x)))\n ans.append(x^int(s))\nprint(*ans)", 'N = int(input())\na = [int(i) for i in input().split()]\nans = []\ns = 0\nfor x in a:\n s = s^x\nfor x in a:\n ans.append(x^s)\nprint(*ans)'] | ['Wrong Answer', 'Accepted'] | ['s366847821', 's142476045'] | [31616.0, 31528.0] | [250.0, 178.0] | [138, 137] |
p02631 | u035044350 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ["import functools\nN = int(input())\nnumbers = list(map(int,input().split()))\nxor = ''\nfor i in range(len(numbers)):\n othersNumbers = numbers[:i] + numbers[i + 1:]\n currentXor = 0\n xor += str(functools.reduce(lambda x,y:x^y,othersNumbers)) + ' '\n \nprint(xor)", "N = int(input())\nnumbers = list(map(i... | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s434175050', 's734912270', 's037331552'] | [31904.0, 31512.0, 31616.0] | [2206.0, 2206.0, 186.0] | [267, 271, 155] |
p02631 | u038404105 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ["n = int(input())\na = list(map(int, input().split()))\nallxor = 0\nfor i in range(n):\n allxor = allxor^a[i]\nans = ''\nfor i in range(n):\n ans= ans +str(allxor^a[i])+' '\nprint(ans)", 'n = int(input())\na = list(map(int, input().split()))\nallxor = 0\nans = [0]*n\nfor i in range(n):\n allxor = allxor^a[i]\... | ['Time Limit Exceeded', 'Accepted'] | ['s560162630', 's745921102'] | [31632.0, 41644.0] | [2206.0, 161.0] | [181, 209] |
p02631 | u076245995 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['N = int(input())\na = list(map(int, input().split()))\nans = []\nfor i in range(N):\n xor = 0\n for j in range(N):\n if i == j:\n xor ^= a[j]\n ans.append(xor)\nprint(*ans)', 'N = int(input())\na = list(map(int, input().split()))\ns = 0\nfor i in range(N):\n s ^= a[i]\n\nans = []\nfor i ... | ['Wrong Answer', 'Accepted'] | ['s031391835', 's362745048'] | [31604.0, 31568.0] | [2206.0, 169.0] | [190, 157] |
p02631 | u126146165 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['n = int(input())\na = list(map(int, input().split()))\nb = 0\nfor i in range(n):\n b ^= a[i]\nans = []\nfor i in range(n):\n ap = b ^ a[i]\n ans.append(ap)\nprint(*a)\nprint(*list(set(ans)))\n', 'n = int(input())\na = list(map(int, input().split()))\nb = 0\nfor i in range(n):\n b ^= a[i]\nans = []\nfor i ... | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s207995763', 's736662845', 's119433354'] | [38496.0, 37576.0, 31636.0] | [288.0, 207.0, 176.0] | [190, 181, 170] |
p02631 | u167681994 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['n = int(input())\na = list(map(int,input().split()))\n\nxor_a = 0\nfor i in range(n):\n xor_a ^= a[i]\n\nprint(xor_a)\n\nans = []\nfor i in range(n):\n ans.append(a[i] ^ xor_a)\n\nprint(*ans)\n', 'n = int(input())\na = list(map(int,input().split()))\n\nxor_a = 0\nfor i in range(n):\n xor_a ^= a[i]\n\n#print(xor_a)... | ['Wrong Answer', 'Accepted'] | ['s995152237', 's192806195'] | [31524.0, 31444.0] | [177.0, 169.0] | [181, 182] |
p02631 | u180812294 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['def xor_operate(a_list):\n result = 0\n for a in a_list:\n result ^= int(a)\n return str(result)\n\n\n\nif __name__ == "__main__":\n N = input()\n a_list = input()\n\n a_list = a_list.split(" ")\n\n i_list = []\n for i in range(len(a_list)):\n r_list = a_list[:i]+a_list[i+1:]\n ... | ['Runtime Error', 'Accepted'] | ['s516478553', 's897820736'] | [9116.0, 41736.0] | [24.0, 186.0] | [387, 370] |
p02631 | u194297606 | 2,000 | 1,048,576 | There are N Snuke Cats numbered 1, 2, \ldots, N, where N is **even**. Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written. Recently, they learned the operation called xor (exclusive OR). What is xor? For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x... | ['N = int(input())\na = list(map(int, input().split()))\nans = []\ns = 0\nfor i in range(N):\n s = s ^ a[i]\n\nfor i in range(N):\n tmp = s ^ a[i]\n ans.append(tmp)\n \nprint(ans)', "N = int(input())\na = list(map(int, input().split()))\nans = []\ns = 0\nfor i in range(N):\n s = s ^ a[i]\n\nfor i in rang... | ['Wrong Answer', 'Accepted'] | ['s279517087', 's267502946'] | [31588.0, 33636.0] | [146.0, 190.0] | [178, 207] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.