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
|
|---|---|---|---|---|---|---|---|---|---|---|
p02707
|
u944886577
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['s=int(input())\ne_list=list(map(int,input().split())\ne_dic={}\nfor i in range(s):\n e_dic[i]+=1\nfor j in e_dic.items\n print(e_dic[j].item)\n ', 's=int(input())\ne_list=list(map(int,input().split()))\n \nm_list=[]\nfor i in range(1,s):\n a=e_list.count(i)\n m_list.append(a)\n\nfor j in m_list:\n print(m_list[s-2-j])', 's=int(input())\ne_list=list(map(int,input().split()))\n\nm_list=[]\nfor i in range(1,s+1):\n m_list[i]=e_list.count(i)\n\nfor i in m_list:\n print(m_list[i])', 's=int(input())\ne_list=dic(map(int,input().split()))\ne_dic\nfor i in range(1,s+1):\n e_dic[i]=e_list.count(i)\n \nfor i in e_dic.keys():\n print(e_dic[i])', 'n=int(input())\nl=list(map(int,input().split()))\n\nans=[0]*n\n\nfor i in l:\n ans[i-1]+=1\n\nfor j in ans:\n print(j)']
|
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
|
['s012789618', 's373291140', 's893267655', 's905959783', 's735278614']
|
[8872.0, 32056.0, 32292.0, 9140.0, 32132.0]
|
[27.0, 2206.0, 71.0, 26.0, 147.0]
|
[149, 164, 151, 150, 115]
|
p02707
|
u945200821
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
["import sys\nfrom collections import Counter\nfrom typing import Callable, NoReturn, Tuple\n\n\ndef main() -> NoReturn:\n scan: Callable[[], str] = sys.stdin.readline\n\n n: int = int(scan().rstrip())\n a: Tuple[int] = tuple(int(a_i) for a_i in scan().rstrip().split())\n\n count: Counter = Counter(a)\n\n for i in range(n):\n print(count[i])\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom collections import Counter\nfrom typing import Callable, NoReturn, Tuple\n\n\ndef main() -> NoReturn:\n scan: Callable[[], str] = sys.stdin.readline\n\n n: int = int(scan().rstrip())\n a: Tuple[int] = tuple(int(a_i) for a_i in scan().rstrip().split())\n\n count: Counter = Counter(a)\n\n for i in range(1, n + 1):\n print(count[i])\n\n\nif __name__ == '__main__':\n main()\n"]
|
['Wrong Answer', 'Accepted']
|
['s882404851', 's043298718']
|
[34524.0, 34316.0]
|
[181.0, 198.0]
|
[390, 397]
|
p02707
|
u945335181
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['from collections import Counter\nN = int(input())\nfuncionarios = list(map(int,input().split()))\nfor x in Counter(funcionarios).values():\n print(x)\n\nprint(0)\n', 'N = int(input())\nfuncionarios = list(map(int,input().split()))\nfrequencia = [0 for i in range(N)]\n\nfor i in funcionarios:\n frequencia[i-1] += 1\n\nfor i in frequencia:\n print(i)\n']
|
['Wrong Answer', 'Accepted']
|
['s226789046', 's784628095']
|
[34020.0, 32172.0]
|
[140.0, 153.0]
|
[159, 182]
|
p02707
|
u949234226
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['#--management\n\nmember = int(input())\nmem_number = [int(i) for i in input().split()]\n\nans = []\n\nfor i in range(member):\n ans.append(0)\n\nprint(ans)\n\nfor j in range(1,member):\n k = mem_number.count(j)\n ans[j-1] = k\n\nfor i in range(member):\n print(ans[i])\n\n', '#--management\n\nmember = int(input())\nmem_number = [int(i) for i in input().split()]\n\nans = []\n\nans = [0] * member\nprint(ans)\n\nfor j in range(1,member):\n k = mem_number.count(j)\n ans[j-1] = k\n\nfor i in range(member):\n print(ans[i])\n', '#--management\nfrom collections import Counter\n\nmember = int(input())\nmem_number = [int(i) for i in input().split()]\n\nans = []\n\nans = [0] * member\n\nmycounter = Counter(mem_number)\n\nfor i in range(member):\n ans[i] = mycounter[i+1]\n print(ans[i])\n ']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s160453400', 's721224446', 's352158765']
|
[32192.0, 32192.0, 35476.0]
|
[2206.0, 2206.0, 185.0]
|
[258, 235, 248]
|
p02707
|
u949831615
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N = input()\nA = input().split()\n\nfor i in range(int(N-1)):\n print(A.count(str(i+1)))', 'N = input()\nA = input().split()\n\nfor i in range(len(A)):\n print(A.count(str(i)))', 'N = input()\nA = input().split()\n\nfor i in range(len(A)):\n print(A.count(str(i+1)))', "n = int(input())\nA = list(map(int, input().split()))\nB = [0] * (n+1)\n\nfor a in A:\n B[a] += 1\n\nprint('\\n'.join(map(str, B[1:])))"]
|
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s074277481', 's323211843', 's931033372', 's862828979']
|
[24104.0, 24072.0, 24116.0, 34120.0]
|
[36.0, 2206.0, 2206.0, 117.0]
|
[85, 81, 83, 130]
|
p02707
|
u951582245
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\nN = int(input())\nt = list(map(int, input().split()))\n\nC = collections.Counter(t)\nans = [0]*N\nfor i in range(N):\n ans[i] = C[i+1]\n \nprint(ans)', 'import collections\nN = int(input())\nt = list(map(int, input().split()))\n\nC = collections.Counter(t)\nfor i in range(N):\n print(C[i+1])']
|
['Wrong Answer', 'Accepted']
|
['s333195234', 's472376413']
|
[34036.0, 33860.0]
|
[153.0, 189.0]
|
[166, 136]
|
p02707
|
u953379577
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\n\nn = int(input())\nbase = input().split()\nx = []\nfor i in base:\n x.append(int(i))\n#x.sort(reverse = False)\nc = collections.Counter(x)\nfor i in range(1,n):\n print(c[i])', 'import collections\n\nn = int(input())\nbase = input().split()\nx = []\nfor i in base:\n x.append(int(i))\n#x.sort(reverse = False)\nc = collections.Counter(x)\nfor i in range(1,n):\n print(c[i])\nprint(0)']
|
['Wrong Answer', 'Accepted']
|
['s815596651', 's736348844']
|
[47608.0, 47832.0]
|
[207.0, 215.0]
|
[191, 200]
|
p02707
|
u955135274
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\n\nn = int(input())\na = list(map(int, input().split()))\nac = collections.Counter(a)\n\nfor i in range(1,n+1):\n print(a[i])', 'import collections\n \nn = int(input())\na = list(map(int, input().split()))\nac = collections.Counter(a)\n \nfor i in range(1,n+1):\n print(ac[i])']
|
['Runtime Error', 'Accepted']
|
['s432070146', 's982487493']
|
[34024.0, 33872.0]
|
[160.0, 178.0]
|
[140, 143]
|
p02707
|
u957669641
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['num = int(input())\nli = list(int(x) for x in input().split())\nli2 = [0] * num\nnum = len(li)\nfor i in li:\n li2[i - 1] = li2[i - 1] + 1\nfor j in range(num):\n print(li2[j])', 'num = int(input())\nli = list(int(x) for x in input().split())\nli2 = [0] * num\nnum = len(li)\nfor i in li:\n li2[i - 1] = li2[i - 1] + i\nfor j in range(num):\n print(li2[j])\n ', 'num = int(input())\nli = list(int(x) for x in input().split())\nli2 = [0] * num\nnum = len(li)\nfor i in li:\n li2[i - 1] = li2[i - 1] + 1\nfor j in range(num + 1):\n print(li2[j])']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s436653675', 's965066059', 's676398171']
|
[32368.0, 32292.0, 32376.0]
|
[174.0, 179.0, 174.0]
|
[171, 174, 175]
|
p02707
|
u959567386
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import numpy as np\n\nN = int(input())\nstaff = list(map(int, input().split()))\n\nboss=[0]*N\n\nfor x in staff:\n boss[x-1] += 1\nprint(list)', 'import numpy as np\n\nN = int(input())\nA = list(map(int,input().split()))\n\nboss=[0]*N\n\nfor x in A:\n boss[x-1] += 1\nfor i in boss:\n print(int(boss[i]))', 'import numpy as np\n\nN = int(input())\nA = list(map(int,input().split()))\n\nboss=[0]*N\n\nfor x in A:\n boss[x-1] += 1\nfor i in boss:\n print(i)']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s784212946', 's856150818', 's382200517']
|
[50924.0, 50844.0, 50832.0]
|
[163.0, 240.0, 219.0]
|
[136, 154, 143]
|
p02707
|
u961945062
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\nN = int(input())\nA = deque(map(int, input().split()))\n\nC = collections.Counter(A)\n\nfor i in range(1, N+1):\n if i in C.keys():\n print(C[i])\n else:\n print(0)', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\n\nC = collections.Counter(A)\n\nfor i in range(1, N+1):\n if i in C.keys():\n print(C[i])\n else:\n print(0)']
|
['Runtime Error', 'Accepted']
|
['s032685372', 's621010654']
|
[9484.0, 34100.0]
|
[21.0, 180.0]
|
[194, 193]
|
p02707
|
u962423738
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['n=int(input())\na=list(map(int,input().split()))\n \nfor i in (1,n+1):\n\tprint(a.count(i))', 'n=int(input())\na=list(map(int,input().split()))\n\nfor i in (1,n+1)\n\tprint(a.count(i))', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\ncount = collections.Counter(A)\nfor n in range(N):\n print(count[n+1])']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s108776264', 's255886215', 's568612570']
|
[32056.0, 8896.0, 34040.0]
|
[78.0, 25.0, 191.0]
|
[86, 84, 141]
|
p02707
|
u964494353
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import numpy as np\nN = int(input())\nA = list(map(int, input().split()))\nL = np.zeros(N)\nfor x in A:\n L[x-1] =+ 1\nfor y in L:\n print(int(y))', 'import numpy as np\nN = int(input())\nA = list(map(int, input().split()))\nL = np.zeros(N)\nfor x in A:\n L[x-1] += 1\nfor y in L:\n print(int(y))']
|
['Wrong Answer', 'Accepted']
|
['s289779215', 's768026914']
|
[50964.0, 50848.0]
|
[254.0, 317.0]
|
[145, 145]
|
p02707
|
u964521959
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['\nN = int(input())\n\nA_list = list(map(int, input().split()))\n\nans = 0\nfor i in range(len(A_list)):\n ans = A_list.count(i+1)\n print(ans)\n\n', '\nN = int(input())\n\nA_list = list(map(int, input().split()))\n\nans = 0\nfor i in range(len(A_list)):\n ans = A _list.count(i+1)\n print(ans)', '\nN = int(input())\n\nA_list = list(map(int, input().split()))\n\nans = 0\n \n \nans_list = [0]*N\n \nfor i in range(len(A_list)):\n \n ans_list[A_list[i]-1]+=1\n\n\nfor i in range(len(ans_list)):\n print(ans_list[i])']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s064319419', 's756433246', 's164118048']
|
[32220.0, 9024.0, 32368.0]
|
[2206.0, 23.0, 160.0]
|
[203, 202, 296]
|
p02707
|
u969211566
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
["n = int(input())\na = list(map(int,input().split()))\nans = [0] * n\nans[0] = a.count(1)\n\nfor i in range(n-1):\n cnt = 0\n for j in range(i,n-1):\n if a[i] == a[j] - 1:\n cnt += 1\n ans[i+1] = cnt\n\nprint(*ans,sep='\\n')\n", 'from collections import Counter\n\nn = int(input())\na = list(map(int,input().split()))\nc = Counter(a)\n\nfor i in range(1,n+1):\n print(c[i])']
|
['Wrong Answer', 'Accepted']
|
['s464539750', 's631980396']
|
[32300.0, 34088.0]
|
[2206.0, 192.0]
|
[238, 139]
|
p02707
|
u971124021
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\n\nm = Counter(a)\n\nfor i in range(1,n):\n print(m[i])\n ', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\n\nm = Counter(a)\n\nfor i in range(1,n+1):\n print(m[i])']
|
['Wrong Answer', 'Accepted']
|
['s964822936', 's656444966']
|
[34112.0, 33992.0]
|
[195.0, 187.0]
|
[138, 137]
|
p02707
|
u982152304
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
["N = int( input())\na = list(map(int, input().split(' ')))\nl = [0]*N\nnumpy.sort(a)\nfor i in a:\n l[i-1] += 1\nfor i in l:\n print(i)", "N = int( input())\na = list(map(int, input().split(' ')))\nl = [0]*N\nnumpy.sort(a)\nfor i in a:\n l[i-1] += 1\nfor i in l:\n print(i)", "import numpy\nN = int( input())\na = list(map(int, input().split(' ')))\nl = [0]*N\nnumpy.sort(a)\nfor i in a:\n l[i-1] += 1\nfor i in l:\n print(i)"]
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s345201149', 's345805222', 's048172257']
|
[32296.0, 32292.0, 50880.0]
|
[67.0, 65.0, 252.0]
|
[131, 133, 146]
|
p02707
|
u982471399
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N= int(input())\nA=list(map(int,input().split()))\n\n\ncnt=[0]*N\nfor i in range(1,N):\n cnt[A[i-1]-1]=cnt[A[i-1]-1]+1\nprint(cnt)', 'N= int(input())\nA=list(map(int,input().split()))\n\n\ncnt=[0]*N\nfor i in range(1,N):\n cnt[A[i-1]-1]=cnt[A[i-1]-1]+1\n\nfor c in cnt:\n print(c)']
|
['Wrong Answer', 'Accepted']
|
['s378699568', 's699927101']
|
[32288.0, 32364.0]
|
[134.0, 180.0]
|
[124, 139]
|
p02707
|
u984276646
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N = int(input())\nD = {i: [] for i in range(N)}\nA = list(map(int, input().split()))\nfor i in range(N-1):\n D[i].append(A[i]-1)\nfor i in range(N):\n print(len(D[i]))', 'N = int(input())\nD = {i: [] for i in range(N)}\nA = list(map(int, input().split()))\nfor i in range(N):\n D[i].append(A[i]-1)\nfor i in range(N):\n print(len(D[i]))', 'N = int(input())\nD = {i: [] for i in range(N)}\nA = list(map(int, input().split()))\nfor i in range(N-1):\n D[A[i]-1].append(i)\nfor i in range(N):\n print(len(D[i]))\n']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s475926488', 's605751721', 's605465063']
|
[63268.0, 63076.0, 62856.0]
|
[266.0, 178.0, 301.0]
|
[163, 161, 164]
|
p02707
|
u985041094
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\nfor ret in c.values():\n print(ret)\nprint(0)', 'import collections\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\nfor i in range(1,n+1):\n print(c[i])']
|
['Wrong Answer', 'Accepted']
|
['s434649859', 's863836083']
|
[34048.0, 34040.0]
|
[137.0, 169.0]
|
[145, 137]
|
p02707
|
u985949234
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N = int(input())\nls = list(map(int, input()))\nanls = [0]*(N+1)\nfor i in ls:\n anls[i] += 1\nfor i in range(1,N+1):\n print(anls[i])\n', 'N = int(input())\nls = list(map(int, input().split()))\nanls = [0]*(N+1)\nfor i in ls:\n anls[i] += 1\nfor i in range(1,N+1):\n print(anls[i])\n\n']
|
['Runtime Error', 'Accepted']
|
['s811965926', 's201720594']
|
[11392.0, 32252.0]
|
[26.0, 147.0]
|
[135, 144]
|
p02707
|
u989699565
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N = int(input())\nAs = list(map(int, input().split()))\nans = [0] * N\n\nfor i in As:\n ans[i]+=1\n\nfor j in ans:\n print(j)', 'N = int(input())\nAs = list(map(int, input().split()))\nans = [0] * N\n\nfor i in As:\n ans[i-1]+=1\n\nfor j in ans:\n print(j)']
|
['Wrong Answer', 'Accepted']
|
['s250728145', 's016493581']
|
[32276.0, 32252.0]
|
[142.0, 144.0]
|
[123, 125]
|
p02707
|
u991269553
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\nimport numpy as np\n\nn = int(input())\na = list(map(int,input().split()))\n\nzero = np.zeros(n+1)\nc = collections.Counter(a)\n\nfor val,key in c.items():\n zero[val] = key\n\nfor i in range(len(zero)):\n if i > 0:\n print(zero[i])', 'import numpy as np\n\nn = int(input())\na = list(map(int,input().split()))\n\nall = np.zeros(n+1)\n\nfor j in range(1,n+1):\n for i,a_i in enumerate(a):\n if j == a_i:\n all[a_i] += 1\nfor i in range(len(all)):\n if i >= 1:\n print(all[i])', 'import numpy as np\n\nn = int(input())\na = list(map(int,input().split()))\n\nall = np.zeros(n+1)\n\nfor j in range(1,n+1): #Ai\n for i,a_i in enumerate(a):\n if i + 1 < a_i:\n pass\n else:\n if j == a_i:\n all[a_i] += 1\n\nfor i in range(1,len(all)):\n print(all[i])', 'import collections\nimport numpy as np\n\nn = int(input())\na = list(map(int,input().split()))\n\nzero = np.zeros(n+1)\nc = collections.Counter(a)\n\nfor val,key in c.items():\n zero[val] = key\n\nfor i in range(len(zero)):\n if i > 0:\n print(int(zero[i]))\n']
|
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s408832207', 's601335841', 's604383481', 's693612793']
|
[54212.0, 50960.0, 51016.0, 54388.0]
|
[280.0, 2206.0, 2206.0, 313.0]
|
[252, 258, 321, 258]
|
p02707
|
u993310962
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['import collections\nn=int(input())\na=list(map(int, input().split()))\nc=collections.Counter(a)\nfor i in range(n):\n print(c[i])', 'import collections\nn=int(input())\na=list(map(int, input().split()))\nc=collections.Counter(a)\nfor i in range(1,n+1):\n print(c[i])']
|
['Wrong Answer', 'Accepted']
|
['s829174060', 's471539055']
|
[33976.0, 34184.0]
|
[189.0, 186.0]
|
[127, 131]
|
p02707
|
u995419623
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['n=int(input())\na=list(map(int,input().split()))\nb=[0]*(n)\n\nfor i in a:\n b[i]+=1\n\nprint(b for _ in range(n-1))', 'n=int(input())\na=list(map(int, input().split()))\nb=[0]*n\n\nfor i in a:\n b[i-1] += 1\n\nfor i in range(n):\n print(b[i])']
|
['Wrong Answer', 'Accepted']
|
['s559227182', 's075590592']
|
[32376.0, 32376.0]
|
[83.0, 155.0]
|
[110, 117]
|
p02707
|
u996506712
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['n=int(input())\na=list(map(int,input().split()))\nans=[0]*n\nfor i in range(n-1):\n ans[a[i]-1] += 1\nfor i in range(n-1):\n print(ans[i])', 'n=int(input())\na=list(map(int,input().split()))\nans=[0]*n\nfor i in range(n):\n ans[a[i]-1] += 1\nfor i in range(n):\n print(ans[i])\n', 'n=int(input())\na=list(map(int,input().split()))\nans=[0]*n\nfor i in range(n-1):\n ans[a[i]-1] += 1\nfor i in range(n):\n print(ans[i])']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s116370181', 's285858122', 's259380042']
|
[32240.0, 32364.0, 32260.0]
|
[163.0, 100.0, 164.0]
|
[138, 135, 136]
|
p02707
|
u997389162
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['n = input()\nl = list(map(int,input().split()))\nfor i in l:\n a = l.count(i+1)\n print(a)', 'from collections import Counter\nn = input()\nl = input().split()\nlt = [int(i) for i in l]\nf = Counter(l)\nfor i in lt:\n print(f[str(i+1)])\n', 'from collections import Counter\nn = list(range(int(input())))\nl = input().split()\nlt = [int(i) for i in l]\nf = Counter(l)\nfor i in n:\n print(f[str(i+1)])']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s169758655', 's808209382', 's993904631']
|
[32252.0, 47592.0, 56708.0]
|
[2206.0, 259.0, 259.0]
|
[92, 140, 156]
|
p02707
|
u997927785
| 2,000
| 1,048,576
|
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has.
|
['N = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N-1):\n count = A.count(i+1)\n print(count)', 'N = int(input())\nA = list(map(int, input().split()))\n\nbukaList = []\nfor i in range(N-1):\n count = A.count(i+1)\n bukaList.append(count)\n\n\nfor k in range(N-1):\n print(bukaList[k])\n\n', 'N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nbuka = [0 for _ in range(N)]\n\nfor i in range(N-1):\n buka[A[i]-1] += 1\n\nfor k in range(N):\n print(buka[k])\n']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s206035175', 's999149213', 's803063643']
|
[32196.0, 32328.0, 32232.0]
|
[2206.0, 2206.0, 167.0]
|
[116, 188, 176]
|
p02709
|
u002625175
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['import sys\nfrom collections import defaultdict\n\nsys.setrecursionlimit(4000)\n\nn = int(input())\narr = map(int, input().split())\narr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))\n\ndp = {}\ndef cal(ln, rn):\n if ln + rn > n:\n return\n\n if ln > 0 or rn > 0:\n idx = ln + rn - 1\n p, a = arr[idx]\n val_l = dp[ln - 1, rn] + a * abs(p - (ln - 1)) if ln > 0 else 0\n val_r = dp[ln, rn - 1] + a * abs(p - (n - rn)) if rn > 0 else 0\n\n dp[ln, rn] = max(val_l, val_r)\n else:\n dp[ln, rn] = 0\n\n cal(ln + 1, rn)\n cal(ln, rn + 1)\n\ncal(0, 0)\n\nprint(max([dp[i, n - i] for i in range(n + 1)]))\n', '\ndef main():\n\n n = int(input())\n arr = map(int, input().split())\n arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))\n\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n for i, (p, a) in enumerate(arr):\n for l in range(i + 1):\n dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + a * abs(p - (n - (i - l) - 1)))\n dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + a * abs(p - l))\n\n print(max(dp[n]))\n\nmain()\n']
|
['Runtime Error', 'Accepted']
|
['s737026523', 's739910291']
|
[11756.0, 135968.0]
|
[29.0, 1947.0]
|
[605, 423]
|
p02709
|
u038724782
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['n = int(input())\nA_l = [(A,i) for i, A in enumerate(map(int,input().split()))]\nA_l.sort()\nA_l.reverse()\n\ndp = []\nfor _ in range(n+1):\n dp.append([0] * (n+1))\nfor j in range(1,n+1): # all go bigger\n yb = n - (j-1)\n a, i = A_l[j-1]\n dp[j][0] = dp[j-1][0] + a*(yb-(i+1))\nfor k in range(1,n+1): # all go smaller\n ys = 1 + (k-1)\n a, i = A_l[k-1]\n dp[0][k] = dp[0][k-1] + a*((i+1)-ys)\n\nfor j in range(1,n+1):\n for k in range(1,n-j+1):\n yb = n - (j-1)\n ys = 1 + (k-1)\n a, x = A_l[j+k-1]\n j_plus = a*(yb-(i+1))\n k_plus = a*((i+1)-ys)\n dp[j][k] = max(dp[j-1][k]+j_plus, dp[j][k-1]+k_plus)\n\nresult = 0\nfor j in range(0,n+1):\n k = n-j\n result = max(result, dp[j][k])\nprint(result)\n#for l in range(n+1):\n# print(dp[l])', 'n = int(input())\nA_l = [(A,i) for i, A in enumerate(map(int,input().split()))]\nA_l.sort(reverse=True)\n\ndp = []\nfor _ in range(n+1):\n dp.append([0] * (n+1))\nfor j in range(1,n+1): # all go bigger\n a, i = A_l[j-1]\n dp[j][0] = dp[j-1][0] + a*(n-(j-1) - (i+1))\nfor k in range(1,n+1): # all go smaller\n a, i = A_l[k-1]\n dp[0][k] = dp[0][k-1] + a*((i+1) - (1+(k-1)))\n\nfor j in range(1,n+1):\n for k in range(1,n-j+1):\n a, i = A_l[j+k-1]\n j_plus = a*(n-(j-1) - (i+1))\n k_plus = a*((i+1) - (1+(k-1)))\n dp[j][k] = max(dp[j-1][k]+j_plus, dp[j][k-1]+k_plus)\n\nresult = 0\nfor j in range(0,n+1):\n k = n-j\n result = max(result, dp[j][k])\nprint(result)\n#for l in range(n+1):\n# print(dp[l])']
|
['Wrong Answer', 'Accepted']
|
['s550454845', 's079472314']
|
[119904.0, 124536.0]
|
[1982.0, 1958.0]
|
[781, 727]
|
p02709
|
u044220565
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['# coding: utf-8\nimport numpy as np\nN = int(input())\n_A = sorted(enumerate(map(int, input().split()), 1), key=lambda x:x[1], reverse=True)\ndp = np.zeros((N+1, N+1))\n\nfor i in range(1,N+1):\n k, Ak = _A[i-1]\n if (N-i-k) < 0:break\n dp[0,i] = dp[0,i-1] + (N-i+1-k) * Ak\n\nfor i in range(1,N+1):\n k, Ak = _A[i-1]\n if (k-i) < 0:break\n dp[i,0] = dp[i-1,0] + (k-i) * Ak\n\nfor x in range(1, N+1):\n for y in range(1, N-x+1):\n k, val = _A[x+y-1]\n dp[x,y]= max((k-x > 0)*(dp[x-1, y] + (k-x)*val),\n (N-y-k+1 > 0)*(dp[x, y-1] + (N-y-k+1) * val))\n\nprint(max(dp[i, N-i] for i in range(N+1)))', '# coding: utf-8\nN = int(input())\n_A = sorted(enumerate(map(int, input().split()), 1), key=lambda x:x[1], reverse=True)\ndp = [[0] * (N+1) for i in range(N+1)]\n\nfor i in range(1,N+1):\n k, Ak = _A[i-1]\n if (N-i-k) < 0:break\n dp[0][i] = dp[0][i-1] + (N-i+1-k) * Ak\n\nfor i in range(1,N+1):\n k, Ak = _A[i-1]\n if (k-i) < 0:break\n dp[i][0] = dp[i-1][0] + (k-i) * Ak\n\nfor x in range(1, N+1):\n for y in range(1, N-x+1):\n k, val = _A[x+y-1]\n dp[x][y]= max(dp[x-1][y] + abs(k-x)*val,\n dp[x][y-1] + abs(N-y-k+1) * val)\n\nprint(int(max(dp[i][N-i] for i in range(N+1))))\n']
|
['Wrong Answer', 'Accepted']
|
['s084008956', 's477863541']
|
[32280.0, 135912.0]
|
[2206.0, 1924.0]
|
[627, 611]
|
p02709
|
u102461423
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['import numpy as np', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\nN = int(readline())\nA = np.array(read().split(), np.int64)\nI = np.argsort(A)[::-1].tolist()\nA = A[I].tolist()\n\ndp = np.zeros(1, np.int64)\n\nfor n, (i, x) in enumerate(zip(I, A)):\n newdp = np.zeros(len(dp) + 1, np.int64)\n left_ind = np.arange(len(dp))\n right_ind = N - 1 - n + left_ind\n left_cost = x * np.abs(left_ind - i)\n right_cost = x * np.abs(right_ind - i)\n np.maximum(newdp[:-1], dp + right_cost, out=newdp[:-1])\n np.maximum(newdp[1:], dp + left_cost, out=newdp[1:])\n dp = newdp\n\nprint(dp.max())\n']
|
['Wrong Answer', 'Accepted']
|
['s767903442', 's596297557']
|
[27140.0, 27992.0]
|
[105.0, 141.0]
|
[18, 662]
|
p02709
|
u155659281
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['AAwIdx = [[0]*2 for _ in range(N)]\nfor i in range(N):\n AAwIdx[i][0] = i\n AAwIdx[i][1] = AA[i]\nAA_sorted = sorted(AAwIdx, key=lambda x: x[1], reverse=True)\n\nIdx_i = 0\nIdx_f = N-1\nAnsIdx = [0]*N\n#print(Idx_f)\nanswer = 0\nfor i in range(N):\n if Idx_f - AA_sorted[i][0] > AA_sorted[i][0] - Idx_i:\n AnsIdx[AA_sorted[i][0]] = Idx_f\n \n Idx_f -= 1\n else:\n AnsIdx[AA_sorted[i][0]] = Idx_i\n \n Idx_i += 1\n \nfor i in range(N):\n answer += abs(AAwIdx[i][0] - AnsIdx[i])*AAwIdx[i][1]\nanswerb = 0\nIdx_i = 0\nIdx_f = N-1\nAnsIdx = [0]*N\nif Idx_f - AA_sorted[0][0] > AA_sorted[0][0] - Idx_i:\n AnsIdx[AA_sorted[i][0]] = Idx_i\n \n Idx_i += 1\nelse:\n AnsIdx[AA_sorted[i][0]] = Idx_f\n \n Idx_f -= 1\nfor i in range(1,N):\n if Idx_f - AA_sorted[i][0] > AA_sorted[i][0] - Idx_i:\n AnsIdx[AA_sorted[i][0]] = Idx_f\n \n Idx_f -= 1\n else:\n AnsIdx[AA_sorted[i][0]] = Idx_i\n \n Idx_i += 1\n \nfor i in range(N):\n answerb += abs(AAwIdx[i][0] - AnsIdx[i])*AAwIdx[i][1]\n#print(AnsIdx)\nprint(max(answer, answerb))', 'def solve():\n N = int(input())\n #AAwIdx = list(map(int,input().split()))\n AAwIdx = [(i,A) for i, A in enumerate(map(int, input().split()))]\n \n # AAwIdx[i][0] = i\n # AAwIdx[i][1] = AA[i]\n AA_sorted = sorted(AAwIdx, key=lambda x: x[1], reverse=True)\n \n\n answer = [[0]*(N+1) for _ in range(N+1)]\n\n ans_all = 0\n Idx_i = 0\n Idx_f = N-1\n for i in range(0,N):\n for no in range(i+1):\n idxi = i-no\n idxf = Idx_f-no\n ans = answer[i-no][no] + abs(AA_sorted[i][0]-idxi)*AA_sorted[i][1]\n if ans>answer[i+1-no][no]:\n answer[i+1-no][no] = ans\n ans = answer[i-no][no] + abs(AA_sorted[i][0]-idxf)*AA_sorted[i][1]\n if ans>answer[i-no][no+1]:\n answer[i-no][no+1] = ans\n for i in range(N,N+1):\n for no in range(i+1):\n if ans_all<answer[i-no][no]:\n ans_all = answer[i-no][no]\n\n print(ans_all)\nsolve()']
|
['Runtime Error', 'Accepted']
|
['s001981984', 's951815399']
|
[9256.0, 136128.0]
|
[26.0, 1795.0]
|
[1503, 1002]
|
p02709
|
u157020659
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['import sys\nsys.setrecursionlimit(2 ** 2000)\nn = int(input())\na = list(map(int, input().split()))\na = [(i, v) for i, v in enumerate(a)]\na.sort(key=lambda x: x[1], reverse=True)\n\ndp = [[-1] * (m + 1) for m in range(n + 1)]\n\ndef f(m, l):\n if m == n: return 0\n if dp[m][l] != -1: return dp[m][l]\n r = n - m + l - 1\n i, v = a[m]\n if i >= l: dp[m + 1][l + 1] = f(m + 1, l + 1)\n if i <= r: dp[m + 1][l] = f(m + 1, l)\n return max(dp[m + 1][l + 1] + v * (i - l), dp[m + 1][l] + v * (r - i))\nprint(f(0, 0))', 'import sys\nsys.setrecursionlimit(2000 * 2)\nn = int(input())\na = list(map(int, input().split()))\na = [(i, v) for i, v in enumerate(a)]\na.sort(key=lambda x: x[1], reverse=True)\n\ndp = [[-1] * (m + 1) for m in range(n + 1)]\n\ndef f(m, l):\n if m == n: return 0\n if dp[m][l] != -1: return dp[m][l]\n r = n - m + l - 1\n i, v = a[m]\n if i >= l: dp[m + 1][l + 1] = f(m + 1, l + 1)\n if i <= r: dp[m + 1][l] = f(m + 1, l)\n return max(dp[m + 1][l + 1] + v * (i - l), dp[m + 1][l] + v * (r - i))\nprint(f(0, 0))']
|
['Runtime Error', 'Accepted']
|
['s855768339', 's722920541']
|
[9132.0, 72312.0]
|
[23.0, 1131.0]
|
[566, 565]
|
p02709
|
u221998589
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['#import numpy as np\n#import math\n#from decimal import *\n#from numba import njit\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n A = sorted(enumerate(A), key = lambda x: x[1])[::-1]\n\n \n dp = [[0]*(N+1-i) for i in range(N+1)]\n\n for i in range(1,len(A)+1):\n index,a = A[i-1]\n for j in range(i+1):\n if (i-j,j) == (0,0):\n dp[i-j][j] = 0\n elif i-j == 0:\n dp[i-j][j] = dp[i-j][j-1] + (N-j-index)*a\n elif j == 0:\n dp[i-j][j] = dp[i-j-1][j] + (abs(index-(i-j-1)))*a\n else:\n dp[i-j][j] = max(dp[i-j][j-1] + (N-j-index)*a, dp[i-j-1][j] + (abs(index-(i-j-1)))*a)\n\n #print(dp)\n #print(np.max(dp))\n\nmain()\n', '#import numpy as np\n#import math\n#from decimal import *\n#from numba import njit\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n A = sorted(enumerate(A), key = lambda x: x[1])[::-1]\n\n \n dp = [[0]*(N+1-i) for i in range(N+1)]\n\n m = 0\n for i in range(1,len(A)+1):\n index,a = A[i-1]\n for j in range(i+1):\n if (i-j,j) == (0,0):\n dp[i-j][j] = 0\n elif i-j == 0:\n dp[i-j][j] = dp[i-j][j-1] + (N-j-index)*a\n elif j == 0:\n dp[i-j][j] = dp[i-j-1][j] + (abs(index-(i-j-1)))*a\n else:\n dp[i-j][j] = max(dp[i-j][j-1] + (N-j-index)*a, dp[i-j-1][j] + (abs(index-(i-j-1)))*a)\n if i == len(A):\n m = max(m, dp[i-j][j])\n\n #print(dp)\n #print(np.max(dp))\n print(m)\n\nmain()\n']
|
['Wrong Answer', 'Accepted']
|
['s009984562', 's217526113']
|
[114576.0, 114564.0]
|
[1652.0, 1691.0]
|
[803, 893]
|
p02709
|
u316464887
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['def main():\n N = int(input())\n A = list(map(int, input().split()))\n AA = [(v, i) for i, v in enumerate(A)]\n AA.sort(reverse=True)\n dp = [[0] * (N+1) for _ in range(N+1)]\n for i, (a, b) in enumerate(AA, start=1):\n for x in range(i+1):\n y = i - x\n if y == 0:\n dp[x][y] = dp[x-1][y] + abs(b - x+1) * a\n elif x == 0:\n dp[x][y] = dp[x][y-1] + abs(N-y-b) * a\n else:\n dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)\n for i in range(N+1):\n r = max(r, dp[i][N-i])\n return r\nprint(main())\n', 'def main():\n N = int(input())\n A = list(map(int, input().split()))\n AA = [(v, i) for i, v in enumerate(A)]\n AA.sort(reverse=True)\n dp = [[0] * (N+1) for _ in range(N+1)]\n for i, (a, b) in enumerate(AA, start=1):\n for x in range(i+1):\n y = i - x\n if y == 0:\n dp[x][y] = dp[x-1][y] + abs(b - x+1) * a\n elif x == 0:\n dp[x][y] = dp[x][y-1] + abs(N-y-b) * a\n else:\n dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)\n r = 0\n for i in range(N+1):\n r = max(r, dp[i][N-i])\n return r\nprint(main())\n']
|
['Runtime Error', 'Accepted']
|
['s703078641', 's840279400']
|
[136060.0, 136092.0]
|
[1460.0, 1324.0]
|
[635, 645]
|
p02709
|
u345966487
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N,A=open(0);N=int(N);A=sorted((int(x),i)for i,x in enumerate(A.split()));t=[0]*N**2\nfor w in range(1,N):\n a,j=A[w]\n for l in range(N-w):\n r=l+w;t[l*N+r]=max(a*abs(j-l)+t[(l+1)*N+r],a*abs(j-r)+t[l*N+r-1])\nprint(t[N-1])', 'N=int(input());A=sorted((int(x),i)for i,x in enumerate(input().split()));t=[0]*N**2\nfor w in range(N):\n a,j=A[w]\n for l in range(N-w):\n r=l+w;p=a*abs(j-l);t[l*N+r]=max(p+t[(l+1)*N+r],a*abs(j-r)+t[l*N+r-1])if w else p\nprint(t[N-1])']
|
['Wrong Answer', 'Accepted']
|
['s710831575', 's180679017']
|
[135384.0, 135660.0]
|
[1962.0, 2000.0]
|
[218, 231]
|
p02709
|
u432251613
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['def main():\n N = int(input())\n A = list(map(int, input().split()))\n\n \n \n \n\n \n sortedA = sorted(A[[a,i] for i,a in enumerate(A)], reverse=True)\n # DP\n dp = [[0]*(N+1) for _ in range(N+1)]\n for i in range(N):\n for l in range(i+1):\n r = i-l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l]+sortedA[i][0]*abs((N-r-1)-sortedA[i][1]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l]+sortedA[i][0]*abs(l-sortedA[i][1]))\n print(max(dp[N]))\n\nmain()\n', 'def main():\n N = int(input())\n A = list(map(int, input().split()))\n\n \n \n \n\n \n Awithidx = [[a,i] for i,a in enumerate(A)]\n sortedA = sorted(Awithidx, reverse=True)\n # DP\n dp = [[0]*(N+1) for _ in range(N+1)]\n for i in range(N):\n a = sortedA[i][0]\n idx = sortedA[i][1]\n for l in range(i+1):\n r = i-l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l]+a*abs((N-r-1)-idx))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l]+a*abs(l-idx))\n print(max(dp[N]))\n\nmain()\n']
|
['Runtime Error', 'Accepted']
|
['s555940650', 's773409963']
|
[9016.0, 136124.0]
|
[24.0, 1990.0]
|
[803, 836]
|
p02709
|
u510443740
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N = int(input())\nA = list(map(int, input().split()))\n\na = [(i, ai) for i, ai in enumerate(A)]\na = sorted(key=lambda x: x[1], reverse=True)\n\n# import numpy as np\n\n\ndp = [[0] * (N + 1) for _ in range(N + 1)]\n\ndp[0][0] = 0\nfor i, ai in enumerate(a):\n for l in range(i+1):\n r = i - l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ai[1] * ((N-1-r) - ai[0]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + ai[1] * (ai[0] - l))\n\nprint(max(dp[N]))', "def solve(N, A):\n a = [(i, ai) for i, ai in enumerate(A)]\n a.sort(key=lambda x: x[1], reverse=True)\n\n # import numpy as np\n \n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n\n dp[0][0] = 0\n for i, ai in enumerate(a):\n for l in range(i+1):\n r = i - l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ai[1] * ((N-1-r) - ai[0]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + ai[1] * (ai[0] - l))\n\n print(max(dp[N]))\n\nif __name__ == '__main__':\n N = int(input())\n A = list(map(int, input().split()))\n solve(N, A)\n"]
|
['Runtime Error', 'Accepted']
|
['s758459308', 's005136961']
|
[9420.0, 124788.0]
|
[23.0, 1918.0]
|
[492, 605]
|
p02709
|
u554096168
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['from copy import deepcopy\n\nN = int(input())\nA = list(map(int, input().split()))\n\nindex = [i for i in range(N)]\nindex = sorted(index, key=lambda i: A[i], reverse=True)\n\nprint(A)\nprint(index)\n\n\ndef LorR(index, res):\n i = index[0]\n dist = max(i, N - 1 - i)\n end = False\n cand1 = cand2 = 0\n while not end:\n j = i + dist\n if 0 <= j and j < N and not res[j]:\n r = deepcopy(res)\n r[j] = True\n cand1 = A[i] * dist + loop(index[1:], r)\n end = True\n\n j = i - dist\n if 0 <= j and j < N and not res[j]:\n r = deepcopy(res)\n r[j] = True\n cand2 = A[i] * dist + loop(index[1:], r)\n end = True\n\n dist -= 1\n return max(cand1, cand2)\n\n\ndef loop(index, res):\n if not index:\n return 0\n\n num = 0\n a = A[index[0]]\n while num < len(index) and A[index[num]] == a:\n num += 1\n\n cand = [0] * num\n for i in range(num):\n ind = deepcopy(index)\n head = ind.pop(i)\n ind.insert(0, head)\n cand[i] = LorR(ind, res)\n\n return max(cand)\n\n\nprint(loop(index, [False] * N))\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nA = sorted([(val, pos) for pos, val in enumerate(A)], reverse=True)\n\ndp = [0]\nfor i, (val, pos) in enumerate(A):\n ldp = [e + val * abs(pos - (i - r)) for r, e in enumerate(dp)]\n rdp = [e + val * abs(N - 1 - r - pos) for r, e in enumerate(dp)]\n dp = [max(L, R) for L, R in zip(ldp + [0], [0] + rdp)]\n\nprint(max(dp))\n']
|
['Runtime Error', 'Accepted']
|
['s044607980', 's975428801']
|
[32472.0, 9712.0]
|
[2206.0, 1010.0]
|
[1136, 378]
|
p02709
|
u618805180
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N = int(input())\n \nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a,i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n \n prev = curr\n \nprint(max(prev))', 'N = int(input())\n \nA = [int(s) for s in input().split(" ")]\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a,i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n print(curr,k,i)\n prev = curr\n \nprint(max(prev))', 'N = int(input())\nA = [int(s) for s in input().split(" ")]\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a,i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n \n prev = curr\n \nprint(max(prev))']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s105600576', 's303447476', 's724386360']
|
[9216.0, 135064.0, 9448.0]
|
[23.0, 1510.0, 1541.0]
|
[294, 350, 333]
|
p02709
|
u667084803
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort()\n\n\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n \n baby, pos = table.pop()\n for x in range(i+1):\n y = i - x\n\n \n DP[x][0] = DP[x-1][0] + baby * abs(pos-x+1)\n DP[0][y] = DP[x][y-1] + baby * abs(pos-(N-y))\n if x & y:\n DP[x][y] = max(DP[x-1][y] + baby * abs(pos-x+1),\\\n DP[x][y-1] + baby * abs(pos-(N-y)))\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, DP[i][N-i])\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort(reverse=True)\n\n\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n \n baby, pos = table.pop()\n for x in range(i+1):\n y = i - x\n\n \n DP[x][y] = max((DP[x-1][y] + baby * abs(pos-x+1)) * (x>0),\\\n (DP[x][y-1] + baby * abs(pos-(N-y)) * (y>0)))\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, DP[i][N-i])\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort()\n\n\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n \n baby, pos = table.pop()\n for x in range(i+1):\n y = i - x\n\n \n DP[x][0] = DP[x-1][0] + baby * abs(pos-x+1))\n DP[0][y] = DP[x][y-1] + baby * abs(pos-(N-y))\n if x & y:\n DP[x][y] = max((DP[x-1][y] + baby * abs(pos-x+1)),\\\n (DP[x][y-1] + baby * abs(pos-(N-y)))\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, DP[i][N-i])\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort()\n\n\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n \n baby, pos = table.pop()\n \n DP[i][0] = DP[i-1][0] + baby * abs(pos-i+1)\n DP[0][i] = DP[0][i-1] + baby * abs(pos-(N-i))\n for x in range(1,i):\n y = i - x\n\n \n DP[x][y] = max(DP[x-1][y] + baby * abs(pos-x+1),\\\n DP[x][y-1] + baby * abs(pos-(N-y)))\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, DP[i][N-i])\nprint(ans)\n']
|
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s047103229', 's171362891', 's299851950', 's131972415']
|
[104976.0, 137068.0, 8984.0, 137000.0]
|
[2209.0, 2210.0, 23.0, 1998.0]
|
[788, 692, 792, 763]
|
p02709
|
u671861352
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['#!python3\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\nN = 2000\nA = [i for i in range(1, N + 1)]\n\n\ndef main():\n P = [(A[i], i + 1) for i in range(N)]\n P.sort(reverse=True)\n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n for n, p in zip(range(1, N + 1), P):\n x, y = p\n for i in range(n):\n j = n - 1 - i\n left = dp[i][j] + x * abs(y - (i + 1))\n dp[i + 1][j] = max(dp[i + 1][j], left)\n right = dp[i][j] + x * abs(y - (N - j))\n dp[i][j + 1] = max(dp[i][j + 1], right)\n\n ans = max([dp[i][N - i] for i in range(N)])\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', '#!python3\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\n# N = 2000\n\n\n\ndef main():\n P = [(A[i], i + 1) for i in range(N)]\n P.sort(reverse=True)\n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n for n, p in zip(range(1, N + 1), P):\n x, y = p\n for i in range(n):\n j = n - 1 - i\n left = dp[i][j] + x * abs(y - (i + 1))\n dp[i + 1][j] = max(dp[i + 1][j], left)\n right = dp[i][j] + x * abs(y - (N - j))\n dp[i][j + 1] = max(dp[i][j + 1], right)\n\n ans = max([dp[i][N - i] for i in range(N)])\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
|
['Wrong Answer', 'Accepted']
|
['s622032012', 's521939755']
|
[128540.0, 136116.0]
|
[1930.0, 1856.0]
|
[664, 668]
|
p02709
|
u707124227
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['from collections import defaultdict\n#n=int(input())\n#a_=list(map(int,input().split()))\nimport numpy as np\nn=2000\na_=range(1,n+1)\na=[]\nfor i,ai in enumerate(a_):\n a.append([1+i,ai])\na.sort(key=lambda x:x[1],reverse=True)\ndp=np.zeros((n+1,n+1),np.int64) \ndp[1,1]=a[0][1]*(n-a[0][0])\ndp[1,0]=a[0][1]*(a[0][0]-1)\nfor i in range(2,n+1):\n dp[i,0]=dp[i-1,0]+a[i-1][1]*abs((a[i-1][0]-1-(i-1))) \n dp[i,i]=dp[i-1,i-1]+a[i-1][1]*abs((n-a[i-1][0]-(i-1))) \n \n l=dp[i-1,1:i]+[a[i-1][1]*abs((a[i-1][0]-1-j))for j in range(i-2,-1,-1)] \n \n r=dp[i-1,:i-1]+[a[i-1][1]*abs((n-a[i-1][0]-j)) for j in range(i-1)] \n dp[i,1:i]=np.maximum(l,r)\nprint(max(dp[n]))\n', "import sys\nimport numpy as np\ndef f(n,a_):\n a=[]\n for i,ai in enumerate(a_):\n a.append([1+i,ai])\n a.sort(key=lambda x:x[1],reverse=True)\n dp=np.zeros((n+1,n+1),np.int64) \n dp[1,1]=a[0][1]*(n-a[0][0])\n dp[1,0]=a[0][1]*(a[0][0]-1)\n for i in range(2,n+1):\n dp[i,0]=dp[i-1,0]+a[i-1][1]*abs((a[i-1][0]-1-(i-1))) \n dp[i,i]=dp[i-1,i-1]+a[i-1][1]*abs((n-a[i-1][0]-(i-1))) \n \n l=dp[i-1,1:i]+[a[i-1][1]*abs((a[i-1][0]-1-j))for j in range(i-2,-1,-1)] \n \n r=dp[i-1,:i-1]+[a[i-1][1]*abs((n-a[i-1][0]-j)) for j in range(i-1)] \n dp[i,1:i]=np.maximum(l,r)\n return max(dp[n])\n\nif __name__ == '__main__':\n input = sys.stdin.readline\n n=int(input())\n a_=list(map(int,input().split()))\n print(f(n,a_))\n"]
|
['Wrong Answer', 'Accepted']
|
['s883389717', 's142304741']
|
[50108.0, 50140.0]
|
[1248.0, 1202.0]
|
[1053, 1206]
|
p02709
|
u837673618
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['from collections import *\nfrom itertools import *\n\nN = int(input())\n\nA = map(int, input().split())\nSA = SB = 0\nABI = sorted((((b:=max(N-i, i-1)*a), (SA:=SA+a), (SB:=SB+b)) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)\n\n\nprint(1)\n', 'N = int(input())\n\ndef solve(a, i, prev):\n r = N - len(prev) - i + 1\n p = -i*a\n for j, s in enumerate(prev):\n yield max(p+abs(j-i)*a, s+abs(j+r)*a)\n p = s\n yield s+abs(len(prev)-i)*a\n\npd = [0]\nA = map(int, input().split())\nfor a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):\n pd = [*solve(a,i, prev)]\n\nprint(max(prev))\n', 'from collections import *\nfrom itertools import *\n\nN = int(input())\n\nA = map(int, input().split())\n\nABI = sorted(((a, max(N-i, i-1)*a, i) for i, a in enumerate(A, 1)), reverse=True)\nSA, SB = map(sum, islice(zip(*ABI), 0, 2))\n\nprev = {(0,0):0}\nprev_max = 0\nfor a, b, i in ABI:\n curr = defaultdict(int)\n curr_max = 0\n for (l,r), p in prev.items():\n if p + SB - min(l,r)*SA < prev_max:\n continue\n curr[l,r+1] = max(curr[l,r+1], p+abs(N-i-r)*a)\n curr[l+1,r] = max(curr[l+1,r], p+abs(i-l-1)*a)\n curr_max = max(curr_max, curr[l,r+1], curr[l+1,r])\n SA -= a\n SB -= b\n prev = curr\n prev_max = curr_max\n print(prev)\n\nprint(curr_max)', 'from collections import *\nfrom itertools import *\n\nN = int(input())\n\nA = map(int, input().split())\nSA = SB = 0\nABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)\n\nprev = {0:0}\nprev_max = 0\nfor k, (a, b, i) in enumerate(ABI, 1):\n curr = defaultdict(int)\n curr_max = 0\n for l, p in prev.items():\n r = k-l\n if p + SB - min(l,r)*SA < prev_max:\n continue\n curr[l] = max(curr[l], p+abs(N-i-r)*a)\n curr[l+1] = p+abs(i-l-1)*a\n curr_max = max(curr_max, curr[l], curr[l+1])\n SA -= a\n SB -= b\n prev = curr\n prev_max = curr_max\n\nprint(curr_max)\n', 'N = int(input())\n\ndef solve(a, i, prev):\n r = N - len(prev) - i + 1\n p = -i*a\n for j, s in enumerate(prev):\n yield max(p+abs(j-i)*a, s+abs(j+r)*a)\n p = s\n yield s+abs(len(prev)-i)*a\n\npd = [0]\nA = map(int, input().split())\nfor a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):\n pd = [*solve(a,i, pd)]\n\nprint(max(prev))\n', 'N = int(input())\n\ndef solve(a, i, prev):\n r = N - len(prev) - i + 1\n p = -i*a\n for j, s in enumerate(prev):\n yield p+abs(j-i)*a, s+abs(j+r)*a\n p = s\n yield s+abs(len(prev)-i)*a,\n\npd = [0]\nA = map(int, input().split())\nfor a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):\n pd = [*map(max, solve(a,i, pd))]\n\nprint(max(pd))\n']
|
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s049940597', 's125297392', 's448210681', 's500880336', 's844029135', 's811407336']
|
[9712.0, 9372.0, 31352.0, 10028.0, 9684.0, 9584.0]
|
[25.0, 26.0, 2241.0, 1443.0, 759.0, 792.0]
|
[241, 348, 647, 622, 346, 350]
|
p02709
|
u870736713
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
["N=int(input())\nactlist=list(map(int,input().split()))\nAs = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]\n\nINF = float('inf')\nleft=1\nright=N\nmaxnum=0\n\ndp = [[-INF] * (N+1) for _ in range(N+1)]\n\ndp[0][0]=0\nfor r in range(N+1):\n for l in range(N-r+1):\n dp[l][r]=max(dp[l][r-1]+As[l+r-1][0]*abs(N-r-As[l+r-1][1]),\\\n dp[l-1][r]+As[l+r-1][0]*abs(l-1-As[l+r-1][1]))\n maxnum=dp[l][r] if maxnum<dp[l][r] else maxnum\n\n \nprint(maxnum)", 'import itertools\n\nN=int(input())\nactlist=list(map(int,input().split()))\nalllist=list(itertools.permutations(range(1,N+1)))\n\ncount=1\n\nhapsum=0\nfor i in range(N-1):\n for j in (i+1,N):\n maxnum=0\n for m,n in zip(alllist[i],alllist[j]):\n hapsum+=actlist[i]*abs(m-n)\n if maxnum<hapsum:\n maxnum=hapsum\n \n\nprint(maxnum)', 'N=int(input())\nactlist=list(map(int,input().split()))\n\nAs = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]\n\nleft=1\nright=N\nsumnum=0\n\nfor i in As:\n move=0\n moveleft=abs(i[1]+1-left)\n moveright=abs(i[1]+1-right)\n if moveleft>moveright:\n move=moveleft\n left+=1\n else:\n move=moveright\n right=right-1\n sumnum+=move*i[0]\n \nprint(sumnum+1)', "def main():\n N = int(input())\n INF = float('inf')\n A = [(i+1, a) for i, a in enumerate(map(int, input().split()))]\n A = sorted(A, key=lambda x: x[1], reverse = True)\n \n dp = [[-INF] * (N+1) for _ in range(N+1)]\n dp[0][0] = 0\n \n for s in range(1, N+1):\n for l in range(s+1):\n r = s - l\n dp[l][r] = max(dp[l-1][r] + A[s-1][1] * abs(A[s-1][0]-l), dp[l][r-1] + A[s-1][1] * abs(N-r+1-A[s-1][0]))\n \n ans = 0\n for m in range(N):\n if(dp[m][N-m] > ans):\n ans = dp[m][N-m]\n \n print(ans)\n \nmain()"]
|
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s603332921', 's784542085', 's844229814', 's461938515']
|
[95736.0, 1790660.0, 9360.0, 136000.0]
|
[2208.0, 2259.0, 23.0, 1689.0]
|
[460, 364, 388, 522]
|
p02709
|
u876160558
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N = int(input())\nA = list(map(int, input().split()))\nacts = [(x, i) for i, x in enumerate(A)]\nacts.sort()\nprint(acts)\ndp = [[-1]*N for _ in range(N)]\n\ndef solve(l, r):\n if r < l:\n return 0\n if dp[l][r] >= 0:\n return dp[l][r]\n k = r - l\n act, init_pos = acts[k]\n gain_l = act * abs(l - init_pos)\n gain_r = act * abs(r - init_pos)\n res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))\n return res\n\nprint(solve(0, N-1))\n', 'import sys\nsys.setrecursionlimit(10**6)\nN = int(input())\nA = list(map(int, input().split()))\nacts = [(x, i) for i, x in enumerate(A)]\nacts.sort()\ndp = [[-1]*N for _ in range(N)]\n \ndef solve(l, r):\n if r < l:\n return 0\n if dp[l][r] >= 0:\n return dp[l][r]\n k = r - l\n act, init_pos = acts[k]\n gain_l = act * abs(l - init_pos)\n gain_r = act * abs(r - init_pos)\n res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))\n return res\n \nprint(solve(0, N-1))']
|
['Runtime Error', 'Accepted']
|
['s576125181', 's718747721']
|
[41612.0, 137900.0]
|
[425.0, 1823.0]
|
[471, 500]
|
p02709
|
u914948583
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['import sys\nsys.setrecursionlimit(10**6)\nN = int(input())\nA = list(map(int, input().split()))\nacts = [(x, i) for i, x in enumerate(A)]\nacts.sort()\ndp = [[-1]*N for _ in range(N)]\n \ndef rec(l, r):\n if r < l:\n return 0\n if dp[l][r] >= 0:\n return dp[l][r]\n k = r - l\n act, init_pos = acts[k]\n gain_l = act * abs(l - init_pos)\n gain_r = act * abs(r - init_pos)\n res = dp[l][r] = max(gain_l + rec(l+1, r), gain_r + rec(l, r-1))\n return res\n \nprint(solve(0, N-1))', "def solve():\n \n N = int(input())\n A = [(a, i+1) for i, a in enumerate(map(int, input().split()))]\n\n A.sort(reverse=True)\n INF = float('inf')\n dp = [[-INF] * (N+1) for _ in range(N+1)]\n dp[0][0] = 0\n\n for s in range(1, N+1):\n for l in range(s+1):\n r = s - l\n dp[l][r] = max(dp[l-1][r] + A[s-1][0] * abs(A[s-1][1]-l), dp[l][r-1] + A[s-1][0] * abs(N-r+1-A[s-1][1]))\n\n ans = 0\n for m in range(N):\n if dp[m][N-m] > ans:\n ans = dp[m][N-m]\n\n print(ans)\nsolve()"]
|
['Runtime Error', 'Accepted']
|
['s748251874', 's314381005']
|
[40708.0, 136172.0]
|
[92.0, 1712.0]
|
[494, 537]
|
p02709
|
u937239245
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['n = int(input())\na = list(map(int, input().split()))\n\na = list(enumerate(a))\na.sort(key = lambda x: x[1], reverse=True)\n\nfor i in range(n):\n a[i][0] = a[i][0] + 1\n\nDP = [[0 for i in range(n+1)] for j in range(n+1)]\nDP[0][0] = 0\nfor i in range(1, n+1):\n DP[0][i] = DP[0][i-1] + abs(a[i-1][1] * (n - i + 1 - a[i-1][0]))\n DP[i][0] = DP[i-1][0] + abs(a[i-1][1] * (a[i-1][0] - i))\n for x in range(1, i):\n y = i - x\n DP[x][y] = max(DP[x-1][y] + abs(a[i-1][1] * (a[i-1][0] - x)), \\\n DP[x][y-1] + abs(a[i-1][1] * (n - y + 1 - a[i-1][0])))\n\nans = 0\nfor i in range(n+1):\n ans = max(ans, DP[i][n-i])\n\nprint(ans) ', 'n = int(input())\na = list(map(int, input().split()))\n\na = list(enumerate(a))\na.sort(key = lambda x: x[1])\n\nDP = [[0 for i in range(n+1)] for j in range(n+1)]\nDP[0][0] = 0\nfor i in range(1, n+1):\n pos, val = a.pop()\n pos = pos + 1\n\n DP[0][i] = DP[0][i-1] + abs(val * (n - i + 1 - pos))\n DP[i][0] = DP[i-1][0] + abs(val * (pos - i))\n for x in range(1, i):\n y = i - x\n DP[x][y] = max(DP[x-1][y] + abs(val * (pos - x)), \\\n DP[x][y-1] + abs(val * (n - y + 1 - pos)))\n\nans = 0\nfor i in range(n+1):\n ans = max(ans, DP[i][n-i])\n\nprint(ans) ']
|
['Runtime Error', 'Accepted']
|
['s080810108', 's266599636']
|
[9324.0, 136900.0]
|
[26.0, 1968.0]
|
[642, 576]
|
p02709
|
u947047288
| 2,000
| 1,048,576
|
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child earns A_x \times |x-y| happiness points. Find the maximum total happiness points the children can earn.
|
['N = int(input())\nA = np.array(list(map(int,input().split())))\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a, i) in enumerate(ABI)\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))\n curr[l+1] = prev[l]+a*abs(i-l-1)\n prev = curr\nprint (max(prev))', 'N = int(input())\nstuff = list(map(int,input().split()))\n\njunban = list(range(N))\n\nmax_happness = 0\nfor subset in permutations(junban):\n happness = 0\n newjunban = (list(subset))\n for i in range(len(junban)):\n happness +=stuff[i]*abs(newjunban[i]-i)\n if happness>max_happness:\n max_happness = happness\nprint (max_happness)', 'N = int(input())\nA = list(map(int,input().split()))\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a, i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))\n curr[l+1] = prev[l]+a*abs(i-l-1)\n prev = curr\nprint (max(prev))']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s324696273', 's658979992', 's444124013']
|
[8920.0, 9212.0, 9436.0]
|
[20.0, 22.0, 1562.0]
|
[349, 373, 340]
|
p02710
|
u002625175
| 2,000
| 1,048,576
|
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors. For each k=1, 2, ..., N, solve the following problem: * Find the number of simple paths that visit a vertex painted in the color k one or more times. **Note:** The simple paths from Vertex u to v and from v to u are not distinguished.
|
["import sys\nimport itertools\n\nsys.setrecursionlimit(3 * 10**5)\n\n\nclass Node:\n def __init__(self, tpl):\n self.id = tpl[0] + 1\n self.c = int(tpl[1])\n self.children = []\n\n def add_child(self, node):\n self.children.append(node)\n\n @staticmethod\n def prepare_nodes(n):\n nodes = tuple(map(Node, enumerate(input().split())))\n for _ in range(n - 1):\n a, b = map(lambda x: int(x) - 1, input().split())\n nodes[a].add_child(nodes[b])\n nodes[b].add_child(nodes[a])\n\n return nodes\n\n\ndef main():\n n = int(input())\n nodes = Node.prepare_nodes(n)\n\n dp = [0 for _ in range(n)]\n ans_list = [n*(n + 1) // 2 for _ in range(n)]\n\n def update_ans(s, color):\n ans_list[color] -= (s + dp[color]) * (s + dp[color] + 1) // 2\n\n def dfs(s, node, parent):\n color = node.c\n pre_s = s + dp[color]\n for child in node.children:\n if child == parent: continue\n\n dp[color] = -s\n s = dfs(s, child, node)\n update_ans(s, color)\n\n s += 1\n dp[color] = pre_s - s\n\n return s\n\n s = dfs(0, nodes[0], Node((-1, -1)))\n\n for i in range(n):\n update_ans(s, i)\n\n print(*ans_list, sep='\\n')\n\n\nmain()\n", 'import sys\nimport itertools\n\nsys.setrecursionlimit(3 * 10**5)\n\n\nclass Node:\n def __init__(self, color):\n self.color = int(color) - 1\n self.children = []\n\n def add_child(self, node):\n self.children.append(node)\n\n @staticmethod\n def prepare_nodes(n):\n nodes = tuple(map(Node, input().split()))\n for _ in range(n - 1):\n a, b = map(lambda x: int(x) - 1, input().split())\n nodes[a].add_child(nodes[b])\n nodes[b].add_child(nodes[a])\n\n return nodes\n\n\ndef main():\n n = int(input())\n nodes = Node.prepare_nodes(n)\n\n dp = [0 for _ in range(n)]\n ans_list = [n*(n + 1) // 2 for _ in range(n)]\n\n def update_ans(s, color):\n ans_list[color] -= (s + dp[color]) * (s + dp[color] + 1) // 2\n\n def dfs(s, node, parent):\n color = node.color\n pre_s = s + dp[color]\n for child in node.children:\n if child == parent: continue\n\n dp[color] = -s\n s = dfs(s, child, node)\n update_ans(s, color)\n\n s += 1\n dp[color] = pre_s - s\n\n return s\n\n s = dfs(0, nodes[0], Node(-1))\n\n for i in range(n):\n update_ans(s, i)\n print(ans_list[i])\n\n\nmain()\n']
|
['Runtime Error', 'Accepted']
|
['s234635592', 's218541061']
|
[311736.0, 306816.0]
|
[1809.0, 1777.0]
|
[1138, 1102]
|
p02710
|
u102461423
| 2,000
| 1,048,576
|
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors. For each k=1, 2, ..., N, solve the following problem: * Find the number of simple paths that visit a vertex painted in the color k one or more times. **Note:** The simple paths from Vertex u to v and from v to u are not distinguished.
|
["import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\n\ndef solve(N, C, AB):\n def edges_to_array(A, B, N, M):\n head = np.full(N + 1, -1, np.int32)\n nxt = np.empty(M + M, np.int32)\n to = np.empty(M + M, np.int32)\n for i in range(M):\n a = A[i]\n b = B[i]\n nxt[i << 1] = head[a]\n to[i << 1] = b\n head[a] = i << 1\n nxt[i << 1 | 1] = head[b]\n to[i << 1 | 1] = a\n head[b] = i << 1 | 1\n return head, nxt, to\n\n def EulerTour(head, nxt, to, root=1):\n N = len(head) - 1\n parent = np.zeros_like(head)\n ind_L = np.empty_like(head)\n ind_R = np.empty_like(head)\n tour = np.empty(N + N, np.int32)\n stack = np.empty(N + N, np.int32)\n stack[0] = -root\n stack[1] = root\n t = -1\n s = 2\n while s > 0:\n s -= 1\n v = stack[s]\n t += 1\n tour[t] = v\n if v > 0:\n ind_L[v] = t\n p = parent[v]\n k = head[v]\n while k != -1:\n w = to[k]\n if w == p:\n k = nxt[k]\n continue\n parent[w] = v\n stack[s] = -w\n s += 1\n stack[s] = w\n s += 1\n k = nxt[k]\n else:\n ind_R[-v] = t\n return tour, ind_L, ind_R, parent\n\n head, nxt, to = edges_to_array(AB[::2], AB[1::2], N, N - 1)\n tour, ind_L, ind_R, parent = EulerTour(head, nxt, to)\n removed = np.zeros(N + 1, np.int64)\n answer = np.full_like(removed, N * (N + 1) // 2)\n memo = np.zeros_like(answer)\n for v in tour:\n if v > 0:\n memo[v] = removed[C[parent[v]]]\n else:\n v = -v\n removed[C[v]] += 1\n p = parent[v]\n x = (ind_R[v] - ind_L[v]) // 2 + 1 # subtree size\n x -= removed[C[p]] - memo[v]\n answer[C[p]] -= x * (x + 1) // 2\n removed[C[p]] += x\n for i, x in enumerate(removed):\n x = N - x\n answer[i] -= x * (x + 1) // 2\n return answer\n\n\ndef cc_export():\n from numba.pycc import CC\n cc = CC('my_module')\n cc.export('solve', '(i8,i4[:],i4[:])')\n cc.compile()\n\n\nif sys.argv[-1] == 'ONLINE_JUDGE':\n cc_export()\n exit()\n\nfrom my_module import solve\nN = int(readline())\nC = np.zeros(N + 1, np.int32)\nC[1:] = np.array(readline().split(), np.int32)\nAB = np.array(read().split(), np.int32)\nanswer = solve(N, C, AB)\nprint('\\n'.join(answer[1:].astype(str)))\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\n\n\ndef solve(N, C, AB):\n def edges_to_array(A, B, N, M):\n head = np.full(N + 1, -1, np.int32)\n nxt = np.empty(M + M, np.int32)\n to = np.empty(M + M, np.int32)\n for i in range(M):\n a = A[i]\n b = B[i]\n nxt[i << 1] = head[a]\n to[i << 1] = b\n head[a] = i << 1\n nxt[i << 1 | 1] = head[b]\n to[i << 1 | 1] = a\n head[b] = i << 1 | 1\n return head, nxt, to\n\n def EulerTour(head, nxt, to, root=1):\n N = len(head) - 1\n parent = np.zeros_like(head)\n ind_L = np.empty_like(head)\n ind_R = np.empty_like(head)\n tour = np.empty(N + N, np.int32)\n stack = np.empty(N + N, np.int32)\n stack[0] = -root\n stack[1] = root\n t = -1\n s = 2\n while s > 0:\n s -= 1\n v = stack[s]\n t += 1\n tour[t] = v\n if v > 0:\n ind_L[v] = t\n p = parent[v]\n k = head[v]\n while k != -1:\n w = to[k]\n if w == p:\n k = nxt[k]\n continue\n parent[w] = v\n stack[s] = -w\n s += 1\n stack[s] = w\n s += 1\n k = nxt[k]\n else:\n ind_R[-v] = t\n return tour, ind_L, ind_R, parent\n\n head, nxt, to = edges_to_array(AB[::2], AB[1::2], N, N - 1)\n tour, ind_L, ind_R, parent = EulerTour(head, nxt, to)\n removed = np.zeros(N + 1, np.int64)\n answer = np.full_like(removed, N * (N + 1) // 2)\n memo = np.zeros_like(answer)\n for v in tour:\n if v > 0:\n memo[v] = removed[C[parent[v]]]\n else:\n v = -v\n removed[C[v]] += 1\n p = parent[v]\n x = (ind_R[v] - ind_L[v]) // 2 + 1 # subtree size\n x -= removed[C[p]] - memo[v]\n answer[C[p]] -= x * (x + 1) // 2\n removed[C[p]] += x\n for i, x in enumerate(removed):\n x = N - x\n answer[i] -= x * (x + 1) // 2\n return answer\n\n\ndef cc_export():\n from numba.pycc import CC\n cc = CC('my_module')\n cc.export('solve', '(i8,i4[:],i4[:])')\n cc.compile()\n\n\ntry:\n from my_module import solve\nexcept:\n cc_export()\n exit()\nN = int(readline())\nC = np.zeros(N + 1, np.int32)\nC[1:] = np.array(readline().split(), np.int32)\nAB = np.array(read().split(), np.int32)\nanswer = solve(N, C, AB)\nprint('\\n'.join(answer[1:].astype(str)))\n", 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n\ndef EulerTour(graph, root=1):\n N = len(graph) - 1\n parent = [0] * (N + 1)\n stack = [-root, root]\n tour = []\n ind_L = [0] * (N + 1)\n ind_R = [0] * (N + 1)\n i = -1\n while stack:\n v = stack.pop()\n tour.append(v)\n i += 1\n if v > 0:\n ind_L[v] = i\n p = parent[v]\n for w in graph[v]:\n if w == p:\n continue\n parent[w] = v\n stack.append(-w)\n stack.append(w)\n else:\n ind_R[-v] = i\n return tour, ind_L, ind_R, parent\n\n\nN = int(readline())\ngraph = [[] for _ in range(N + 1)]\nC = (0,) + tuple(map(int, readline().split()))\nm = map(int, read().split())\nfor a, b in zip(m, m):\n graph[a].append(b)\n graph[b].append(a)\n\ntour, ind_L, ind_R, parent = EulerTour(graph)\n', "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n\ndef solve(N, C, AB):\n def edges_to_array(A, B, N, M):\n head = [-1] * (N + 1)\n nxt = [0] * (M + M)\n to = [0] * (M + M)\n for i in range(M):\n a = A[i]\n b = B[i]\n nxt[i << 1] = head[a]\n to[i << 1] = b\n head[a] = i << 1\n nxt[i << 1 | 1] = head[b]\n to[i << 1 | 1] = a\n head[b] = i << 1 | 1\n return head, nxt, to\n\n def EulerTour(head, nxt, to, root=1):\n N = len(head) - 1\n parent = [0] * (N + 1)\n ind_L = [0] * (N + 1)\n ind_R = [0] * (N + 1)\n i = -1\n tour = []\n stack = [-root, root]\n stack[0] = -root\n stack[1] = root\n while stack:\n v = stack.pop()\n tour.append(v)\n i += 1\n if v > 0:\n ind_L[v] = i\n p = parent[v]\n k = head[v]\n while k != -1:\n w = to[k]\n if w == p:\n k = nxt[k]\n continue\n parent[w] = v\n stack.append(-w)\n stack.append(w)\n k = nxt[k]\n else:\n ind_R[-v] = i\n return tour, ind_L, ind_R, parent\n head, nxt, to = edges_to_array(AB[::2], AB[1::2], N, N - 1)\n tour, ind_L, ind_R, parent = EulerTour(head, nxt, to)\n removed = [0] * (N + 1)\n answer = [N * (N + 1) // 2] * (N + 1)\n memo = [0] * (N + 1)\n for v in tour:\n if v > 0:\n memo[v] = removed[C[parent[v]]]\n else:\n v = -v\n removed[C[v]] += 1\n p = parent[v]\n x = (ind_R[v] - ind_L[v]) // 2 + 1 # subtree size\n x -= removed[C[p]] - memo[v]\n answer[C[p]] -= x * (x + 1) // 2\n removed[C[p]] += x\n for i, x in enumerate(removed):\n x = N - x\n answer[i] -= x * (x + 1) // 2\n return answer\n\n\nN = int(readline())\nC = (0,) + tuple(map(int, readline().split()))\nAB = tuple(map(int, read().split()))\nanswer = solve(N, C, AB)\nprint('\\n'.join(map(str, answer[1:])))\n"]
|
['Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted']
|
['s143798694', 's159682089', 's972729169', 's059654886']
|
[27408.0, 110868.0, 80528.0, 94016.0]
|
[109.0, 2208.0, 768.0, 1055.0]
|
[2739, 2714, 958, 2262]
|
p02710
|
u947047288
| 2,000
| 1,048,576
|
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors. For each k=1, 2, ..., N, solve the following problem: * Find the number of simple paths that visit a vertex painted in the color k one or more times. **Note:** The simple paths from Vertex u to v and from v to u are not distinguished.
|
['#n = 5\n#C = list(map(int,"1 2 3 4 5".split()))\n#line = ["1 2", "2 3", "3 4", "3 5"]\n\n\nn = int(input())\nC = list(map(int,input().split()))\n \nci = [set() for _ in range(n)]\nfor i,c in enumerate(C):\n ci[c-1].add(i)\n\npath = [set() for _ in range(n)]\n \n#line = ["1 2", "2 3"]\n \nfor i in range(n-1):\n #a,b = map(int,input().split())\n a,b = map(int,line[i].split())\n a -= 1\n b -= 1\n path[a].add(b)\n path[b].add(a)\n \nans = [n*(n+1)//2]*n\nsize = [0]*n\ncparent = [[] for _ in range(n)]\nreached = [False]*n\nroot_size = [n]*n\n\ndef dfs (p):\n c = C[p] - 1\n cparent[c].append(p)\n s = 1\n for nxt in path[p]:\n #print (nxt)\n size[p] = 0\n if reached[nxt]:\n continue\n reached[nxt] = True\n ret = dfs(nxt)\n s += ret\n size[p] +=ret\n ans[c] -= size[p] * (size[p] + 1)//2\n cparent[c].pop()\n if cparent[c]:\n size[cparent[c][-1]] -=s\n else:\n root_size[c] -=s \n return s\n\nreached[0] = True\ndfs (0)\n\nfor i in range(n):\n print (ans[i]-root_size[i]*(root_size[i]+1)//2)\n', 'import sys\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.readline\n\nn = int(input())\nC = list(map(int,input().split()))\n\npath = [set() for _ in range(n)]\n\nfor i in range(n-1):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n path[a].add(b)\n path[b].add(a)\n \nans = [n*(n+1)//2]*n\nsize = [0]*n\ncparent = [[] for _ in range(n)]\nreached = [False]*n\nroot_size = [n]*n\n\ndef dfs (p):\n c = C[p] - 1\n cparent[c].append(p)\n s = 1\n for nxt in path[p]:\n #print (nxt)\n \n if reached[nxt]:\n continue\n size[p] = 0\n reached[nxt] = True\n ret = dfs(nxt)\n s += ret\n size[p] +=ret\n ans[c] -= size[p] * (size[p] + 1)//2\n cparent[c].pop()\n if cparent[c]:\n size[cparent[c][-1]] -=s\n else:\n root_size[c] -=s \n return s\n\nreached[0] = True\ndfs (0)\n\nfor i in range(n):\n print (ans[i]-root_size[i]*(root_size[i]+1)//2)']
|
['Runtime Error', 'Accepted']
|
['s264535393', 's802536784']
|
[131760.0, 291736.0]
|
[654.0, 1626.0]
|
[1077, 925]
|
p02710
|
u947883560
| 2,000
| 1,048,576
|
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same color; different integers correspond to different colors. For each k=1, 2, ..., N, solve the following problem: * Find the number of simple paths that visit a vertex painted in the color k one or more times. **Note:** The simple paths from Vertex u to v and from v to u are not distinguished.
|
['#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**8)\nfrom collections import defaultdict\nINF = float("inf")\nMOD = 10**9+7\n\n\nclass Graph(object):\n def __init__(self, N):\n self.N = N\n self.E = defaultdict(list)\n\n def add_edge(self, f, t, w=1):\n self.E[f].append((t, w))\n self.E[t].append((f, w))\n\n\ndef merge(d: dict, e: dict):\n if len(d) < len(e):\n d, e = e, d\n for k in d:\n d[k] += e[k]\n return e\n\n\nN = int(input())\nc = [x-1 for x in map(int, input().split())]\nA = [None]*(N-1)\nB = [None]*(N-1)\nfor i in range(N-1):\n A[i], B[i] = map(int, input().split())\n\ng = Graph(N)\nfor a, b in zip(A, B):\n g.add_edge(a-1, b-1)\n\nans = [0]*N\n\n\ndef f(curr, par=-1):\n ret = defaultdict(int)\n size = 1\n for dest, w in g.E[curr]:\n if dest == par:\n continue\n sz, child = f(dest, curr)\n size += sz\n\n n = sz-child[c[curr]]\n ans[c[curr]] += n*(n+1)//2\n\n \n # if len(ret) < len(child):\n \n # for key in child:\n # ret[key] += child[key]\n ret = merge(ret, child)\n\n ret[c[curr]] = size\n return size, ret\n\n\nsz, ret = f(0)\nfor color in range(N):\n if color != c[0]:\n n = sz-ret[color]\n ans[color] += n*(n+1)//2\n\ntot = N*(N+1)//2\nfor a in ans:\n print(tot-a)\n', '#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**8)\nfrom collections import defaultdict\nINF = float("inf")\nMOD = 10**9+7\n\n\nclass Graph(object):\n def __init__(self, N):\n self.N = N\n self.E = defaultdict(list)\n\n def add_edge(self, f, t, w=1):\n self.E[f].append((t, w))\n self.E[t].append((f, w))\n\n\ndef merge(d: dict, e: dict):\n if len(d) < len(e):\n d, e = e, d\n for k in e:\n d[k] += e[k]\n return e\n\n\nN = int(input())\nc = [x-1 for x in map(int, input().split())]\nA = [None]*(N-1)\nB = [None]*(N-1)\nfor i in range(N-1):\n A[i], B[i] = map(int, input().split())\n\ng = Graph(N)\nfor a, b in zip(A, B):\n g.add_edge(a-1, b-1)\n\nans = [0]*N\n\n\ndef f(curr, par=-1):\n ret = defaultdict(int)\n size = 1\n for dest, w in g.E[curr]:\n if dest == par:\n continue\n sz, child = f(dest, curr)\n size += sz\n\n n = sz-child[c[curr]]\n ans[c[curr]] += n*(n+1)//2\n\n \n # if len(ret) < len(child):\n \n # for key in child:\n # ret[key] += child[key]\n ret = merge(ret, child)\n\n ret[c[curr]] = size\n return size, ret\n\n\nsz, ret = f(0)\nfor color in range(N):\n if color != c[0]:\n n = sz-ret[color]\n ans[color] += n*(n+1)//2\n\ntot = N*(N+1)//2\nfor a in ans:\n print(tot-a)\n', '#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**8)\nfrom collections import defaultdict\nINF = float("inf")\nMOD = 10**9+7\n\n\nclass Graph(object):\n def __init__(self, N):\n self.N = N\n self.E = defaultdict(list)\n\n def add_edge(self, f, t, w=1):\n self.E[f].append(t)\n self.E[t].append(f)\n\n\ndef make_order(g, v):\n seen = [False]*g.N\n last_order = [-1]*g.N\n parent = [-1]*g.N\n size = [1]*g.N\n counter = {"last": 0}\n\n def recur(v):\n seen[v] = True\n for to in g.E[v]:\n if seen[to] == True:\n continue\n parent[to] = v\n recur(to)\n size[v] += size[to]\n\n last_order[counter["last"]] = v\n counter["last"] += 1\n\n recur(v)\n return last_order, parent, size\n\n\ndef merge(d: dict, e: dict):\n if len(d) < len(e):\n d, e = e, d\n for k in e:\n d[k] += e[k]\n return d\n\n\nN = int(input())\nc = [x-1 for x in map(int, input().split())]\nA = [None]*(N-1)\nB = [None]*(N-1)\nfor i in range(N-1):\n A[i], B[i] = map(int, input().split())\n\ng = Graph(N)\nfor a, b in zip(A, B):\n g.add_edge(a-1, b-1)\n\nans = [0]*N\n\nret = {}\nlast_order, parent, size = make_order(g, 0)\nfor curr in last_order:\n cn = c[curr]\n rrr = defaultdict(int)\n for dest in g.E[curr]:\n if dest == parent[curr]:\n continue\n child = ret.pop(dest)\n\n n = size[dest]-child[cn]\n ans[cn] += n*(n+1)//2\n\n \n rrr = merge(rrr, child)\n\n rrr[cn] = size[curr]\n ret[curr] = rrr\n\n\ntot = N*(N+1)//2\nfor color in range(N):\n if color != c[0]:\n n = N-ret[0][color]\n ans[color] += n*(n+1)//2\n print(tot-ans[color])\n']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s240245284', 's779815559', 's903072910']
|
[396220.0, 410832.0, 340348.0]
|
[2216.0, 1941.0, 1838.0]
|
[1365, 1365, 1704]
|
p02711
|
u000037600
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['a=list(int(input()))\nif 7 in a:\n print("Yes")\nelse:\n print("No")', 'a=list(input())\nif \t"7" in a:\n print("Yes")\nelse:\n print("No")']
|
['Runtime Error', 'Accepted']
|
['s258955397', 's556724925']
|
[9180.0, 8996.0]
|
[25.0, 27.0]
|
[66, 64]
|
p02711
|
u000540018
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["S = input()\nif '7' in S:\n print('Yes')\nelse\n print('No')\n", "S = input()\nif '7' in S:\n print('Yes')\nelse:\n print('No')"]
|
['Runtime Error', 'Accepted']
|
['s513110841', 's347561791']
|
[9008.0, 9024.0]
|
[20.0, 20.0]
|
[59, 59]
|
p02711
|
u001495709
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['a = int(input())\nif a[1] == 7 or a[2] == 7 or a[3] == 7 :\n print(Yes)\nelse :\n print(No)', 'a = input()\nif a[0] == \'7\' or a[1] == \'7\' or a[2] == \'7\' :\n print("Yes")\nelse :\n print("No")']
|
['Runtime Error', 'Accepted']
|
['s154769350', 's436588200']
|
[9040.0, 9036.0]
|
[18.0, 22.0]
|
[89, 94]
|
p02711
|
u002611201
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n\nK = int(input())\nans = 0\nfor i in range(K):\n for j in range(K):\n for k in range(K):\n ans += gcd(i+1,j+1,k+1)\n \nprint(ans)', "a = int(input())\nout =[int(x) for x in str(a)]\nans = out.count(7)\nif ans != 0:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s900212274', 's920496562']
|
[9468.0, 9164.0]
|
[2206.0, 20.0]
|
[323, 117]
|
p02711
|
u004823354
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = int(input())\nl = len(N)\nfor i in range(l):\n if N[i] ==7:\n print("Yes")\n exit()\nprint("No") ', 'N = input()\nl = len(N)\nfor i in range(l):\n if N[i] ==7:\n print("Yes")\n exit()\nprint("No") ', 'N = int(input())\nl = len(N)\nfor i in range(l):\n if N.index(i) ==7:\n print("Yes")\n exit()\nprint("No") ', 'N = input()\nl = len(N)\nfor i in range(l):\n if N[i] =="7":\n print("Yes")\n exit()\nprint("No") ']
|
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
|
['s074496625', 's382774655', 's881187246', 's360368135']
|
[9060.0, 8944.0, 8988.0, 8896.0]
|
[24.0, 25.0, 22.0, 25.0]
|
[105, 100, 111, 102]
|
p02711
|
u006425112
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n = input()\nif \'7\' in j:\n print("Yes")\nelse:\n print("No")', 'n = input()\nif \'7\' in n:\n print("Yes")\nelse:\n print("No")']
|
['Runtime Error', 'Accepted']
|
['s071990602', 's597747532']
|
[8960.0, 9092.0]
|
[22.0, 21.0]
|
[59, 59]
|
p02711
|
u008022357
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n = input()\n\nif "7" in n:\n print("YES")\nelse:\n print("NO")', 'n = input()\n\nif "7" in n:\n print("Yes")\nelse:\n print("No")']
|
['Wrong Answer', 'Accepted']
|
['s008474810', 's944173743']
|
[9024.0, 8976.0]
|
[20.0, 24.0]
|
[64, 64]
|
p02711
|
u010070134
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['a = input()\nfor _ in range(3):\n if a % 10 == 7:\n print("Yes")\n return\n a /= 10\nprint("No")\nreturn', 'a = int(input())\nfor _ in range(3):\n if a % 10 == 7:\n print("Yes")\n \tbreak\n a /= 10\nelse:\n print("No")', 'a = input()\nif \'7\' in a:\n print("Yes")\nelse:\n print("No")\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s191994755', 's379272587', 's324686969']
|
[9072.0, 8928.0, 9084.0]
|
[24.0, 19.0, 22.0]
|
[106, 111, 60]
|
p02711
|
u010379708
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['t=int(input())\nS=0\nfor i in list(range(t+1)):\n if i%5!=0 and i%3!=0:\n S += i\nprint(S)', 't=int(input())\nS=0\nfor i in list(range(t+1)):\n if i%5!=0 and i%3!=0:\n sum += i\nprint(S)', 'string = input()\nfound = False\nfor i in string:\n if i == \'7\':\n found=True\n break\n \n \nif found:\n print("Yes")\nelse:\n print("No")\n ']
|
['Wrong Answer', 'Runtime Error', 'Accepted']
|
['s389515061', 's889616726', 's334539678']
|
[9116.0, 8992.0, 9028.0]
|
[22.0, 19.0, 21.0]
|
[89, 91, 147]
|
p02711
|
u013956357
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import math\n \nk = int(input())\n \ntotal = 0\nfor a in range(1,k+1):\n for b in range(1,k+1):\n for c in range(1,k+1):\n total += math.gcd(math.gcd(a,b),c)\n \nprint(total)', "n = input()\n\nfor s in n:\n if s == '7':\n print('Yes')\n exit()\nprint('No')"]
|
['Wrong Answer', 'Accepted']
|
['s301623478', 's426226048']
|
[9164.0, 9024.0]
|
[2205.0, 19.0]
|
[185, 89]
|
p02711
|
u015845133
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['def calc():\n for i in L:\n if L[i] == 7:\n print("Yes")\n else:\n return\n print("No")\n\nN = int,input()\n\nM = str(N)\nprint(M)\n\nL = list(map(int, M))\n\ncalc()', 'N = int,input()\n\nM = str(N)\nprint(M)\n\nL = list(map(int, M))\nprint(L)\n\nif L[0] == 7:\n print("Yes")\n \nelif L[1] == 7:\n print("Yes")\n\nelif L[2] == 7:\n print("Yes")\n\nelse:\n print("No")', 'N = input()\n\nM = str(N)\n\nL = list(map(int, M))\n\nif L[0] == 7:\n print("Yes")\n \nelif L[1] == 7:\n print("Yes")\n\nelif L[2] == 7:\n print("Yes")\n\nelse:\n print("No")']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s298528008', 's511381317', 's742664853']
|
[9108.0, 9184.0, 9180.0]
|
[23.0, 23.0, 20.0]
|
[192, 195, 173]
|
p02711
|
u017634192
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n=str(input())\nt=\'nt\'\nfor(i in range(n)):\n if(n[i]==\'7\'):\n print("Yes")\n t=\'tr\'\nif(t=\'nt\'):\n print("No")', "n=input()\nn=str(n)\nt='nd'\nfor i in n;\n\tif i=='7':\n \tprint('Yes')\n \tt='d'\nif t=='nd':print('No') ", "n=input()\nn=str(n)\nt='nd'\nfor i in n:\n if i=='7':\n print('Yes')\n t='d'\n break\nif t=='nd':print('No') \n"]
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s156798602', 's194327904', 's680315003']
|
[8772.0, 8992.0, 9076.0]
|
[23.0, 20.0, 21.0]
|
[112, 111, 127]
|
p02711
|
u017849462
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import math\nfrom functools import reduce\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\nK = int(input())\nS = 0\n\nfor i in range(1,K+1):\n for j in range(1,K+1):\n for k in range(1,K+1):\n S += gcd(i,j,k)\n\nprint (S)\n', "N = input()\nif '7' in N:\n print('Yes')\nelse :\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s827686667', 's275917870']
|
[9640.0, 9088.0]
|
[2205.0, 19.0]
|
[242, 64]
|
p02711
|
u018679195
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['temp=list(map(int,input().rstrip().split()))\nn=temp[0]\nS=temp[1]\nsumm=0\ncount=0\nwhile summ<S :\n if (S-summ)>=n :\n summ+=n\n\n count+=1\n else :\n count+=1\n break\nprint(count)', "x = str(input())\ny='No'\nfor k in x:\n if k == '7':\n y='Yes'\n\nprint(y)\n"]
|
['Runtime Error', 'Accepted']
|
['s175641061', 's229847849']
|
[8848.0, 9072.0]
|
[22.0, 28.0]
|
[204, 79]
|
p02711
|
u019091985
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['no = input()\nc = false\nwhile no > 0:\n if no%10 == 7:\n c = true\nif c == true:\n print("Yes")\nelse :\n print("No")', 'def check(n):\n\twhile n > 0:\n\t\tif n%10 == 7:\n\t\t\treturn "Yes"\n\t\tn = int(n/10)\n\treturn "No"\n\nno = int(input())\nprint(check(no))']
|
['Runtime Error', 'Accepted']
|
['s388317754', 's246166051']
|
[9096.0, 9104.0]
|
[20.0, 26.0]
|
[116, 124]
|
p02711
|
u019271397
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['word = input().split()\n#print(word)\nif word[0] == "7" :\n print("Yes")\nelif word[1] == "7" :\n print("Yes")\nelif word[2] == "7" :\n print("Yes")\nelse:\n print("No")\n', 'num = lits(input())\nprint(num)\nif num[0] == "7":\n print("Yes")\nelif num[1] == "7":\n print("Yes")\nelif num[2] == "7":\n print("Yes")\nelse:\n print("No")', 'num = input()\nword = list(num)\n#print(word)\nif word[0] == "7" :\n print("Yes")\nelif word[1] == "7" :\n print("Yes")\nelif word[2] == "7" :\n print("Yes")\nelse:\n print("No")\n']
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s347195409', 's623750516', 's752316659']
|
[9088.0, 9040.0, 9100.0]
|
[23.0, 20.0, 23.0]
|
[173, 153, 181]
|
p02711
|
u020801333
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['l = list(map(int, input()))\nif 7 in list:\n print("Yes")\nelse:\n print("No")\n ', 'l = list(map(int, input()))\nif 7 in l:\n print("Yes")\nelse:\n print("No")']
|
['Runtime Error', 'Accepted']
|
['s660998224', 's098220916']
|
[9024.0, 9128.0]
|
[21.0, 20.0]
|
[79, 73]
|
p02711
|
u021500086
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N=input()\n\nif 7 in N:\n print("Yes")\nelse:\n print("No")', 'N=list(map(int,input()))\n\nif 7 in N:\n print("Yes")\nelse:\n print("No")\n']
|
['Runtime Error', 'Accepted']
|
['s480051800', 's978822859']
|
[8984.0, 9052.0]
|
[19.0, 21.0]
|
[56, 72]
|
p02711
|
u023100857
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["n = input()\n#print(n[1])\nif n[0] =='7' or n[1] == '7' or n[2] == '7':\n print('YES')\nelse:\n print('NO')", "n = input()\n#print(n[1])\nif n[0] =='7' or n[1] == '7' or n[2] == '7':\n print('YES')\nelse:\n print('NO')", "n = input()\n#print(n[1])\nif n[0] =='7' or n[1] == '7' or n[2] == '7':\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s512507964', 's879369213', 's026489449']
|
[9096.0, 9032.0, 9096.0]
|
[21.0, 23.0, 21.0]
|
[108, 108, 108]
|
p02711
|
u024782094
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n=int(input())\na=n//100\nb=(n-a*100)//10\nc=n%100\nans="Yes"\nif a!=7 and b!=7 and c!=7:\n ans="No"\nprint(ans)', 'n=input()\nif n[0]!="7" and n[1]!="7" and n[2]!="7":\n print("No")\nelse:\n print("Yes")']
|
['Wrong Answer', 'Accepted']
|
['s980256273', 's790518033']
|
[9172.0, 9096.0]
|
[20.0, 22.0]
|
[106, 86]
|
p02711
|
u026731851
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N=int(input())\nC=str(N)\nc=0\nfor i in range(len(C)):\n if C[i]==7:\n c+=1\nif c==0:\n print("No")\nelse:\n print("Yes")', 'N=int(input())\nC=str(N)\nc=0\nfor i in range(len(C)):\n if int(C[i])==7:\n c+=1\nif c==0:\n print("No")\nelse:\n print("Yes")']
|
['Wrong Answer', 'Accepted']
|
['s380364295', 's480792867']
|
[9168.0, 9172.0]
|
[21.0, 23.0]
|
[118, 123]
|
p02711
|
u027076164
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = std(input())\n\na = N.split()\n\nif 7 in a:\n print("Yes")\nelse:\n print("No")\n\n ', 'N = str(input())\n\nlist = [N[0], N[1], N[2]]\nif 7 in list:\n print("Yes")\nelse:\n print("No")', 'N = input()\n\nlist = [N[0], N[1], N[2]]\nif 7 in list:\n print("Yes")\nelse:\n print("No")\n\n\n ', 'N = str(input())\n\nlist = [N[0], N[1], N[2]]\nif "7" in list:\n print("Yes")\nelse:\n print("No")']
|
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s356157095', 's406489094', 's575525483', 's424498623']
|
[8988.0, 8968.0, 8960.0, 9020.0]
|
[24.0, 20.0, 19.0, 20.0]
|
[82, 92, 92, 94]
|
p02711
|
u027561659
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = input()\nprint(N*(N-1)//2-(3*(N//3)+5*(N//5))+15*(N//15))', 'N = int(input())\nprint(N*(N-1)//2-(3*(N//3)*(N//3-1)+5*(N//5)*(N//5-python\n p1))//2+15*(N//15)*(N//15-1)//2)\n', 'N = int(input())\nprint(N*(N-1)//2-(3*(N//3)*(N//3-1)+5*(N//5)*(N//5-1))//2+15*(N//15)*(N//15-1)//2)', 'print("Yes" if("7"in input())else"No")']
|
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s149265506', 's305307480', 's450465138', 's553880131']
|
[9096.0, 9044.0, 9168.0, 9104.0]
|
[21.0, 21.0, 22.0, 22.0]
|
[60, 154, 99, 38]
|
p02711
|
u028489522
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["x = input().split()\nj = 0\nfor i in x:\n if int(i) != 7:\n j = 1\n\nif j == 0:\n print('Yes')\nelse:\n print('No')", "x = list(input())\nj = 0\nfor i in x:\n print(i)\n if int(i) != 7:\n j = 1\n\nif j == 0:\n print('Yes')\nelse:\n print('No')", "x = list(input())\nj = 0\nfor i in x:\n if int(i) != 7:\n j = 1\n\nif j == 0:\n print('Yes')\nelse:\n print('No')", "x = list(input())\nj = 0\nfor i in x:\n if int(i) == 7:\n j = 1\n\nif j == 1:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s272203255', 's697496902', 's780587973', 's847648525']
|
[9168.0, 9164.0, 9164.0, 9160.0]
|
[20.0, 21.0, 20.0, 24.0]
|
[112, 121, 110, 110]
|
p02711
|
u032955959
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['t=list(input())\n\nif t[0]==7 or t[1]==7 or t[2]==7 :\n\tprint("Yes")\nelse:\n\tprint("No")', 't=list(input())\n\nif t[0]==\'7\' or t[1]==\'7\' or t[2]==\'7\' :\n\tprint("Yes")\nelse:\n\tprint("No")']
|
['Wrong Answer', 'Accepted']
|
['s749429521', 's428510799']
|
[9100.0, 9096.0]
|
[20.0, 25.0]
|
[84, 90]
|
p02711
|
u033523569
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n=int(input()) \nres="No" \nfor i in range(3):\n if n%7==0:\n res="Yes"\n n//=10\nprint (res) ', 'n=int(input()) \n\nres="No" \n\nfor i in range(3):\n\n if n%10==7:\n\n res="Yes"\n\n n//=10\n\nprint (res) \n\n']
|
['Wrong Answer', 'Accepted']
|
['s370971809', 's070805573']
|
[9164.0, 9160.0]
|
[21.0, 23.0]
|
[93, 102]
|
p02711
|
u034400188
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import sys\n\nN = input()\n\nfor i in range(3):\n if (N[i]==\'7\'):\n print("YES")\n sys.exit()\n\nprint("NO")\n', 'import sys\n\nN = input()\n\nfor i in range(3):\n if (N[i]==\'7\'):\n print("YES")\n sys.exit()\n\nprint("NO")\n', 'n = int(input())\nflag = 1\n\nn_1 = (n-(n//10)*10)\nn_10 = (n-(n//100)*100 - n_1)//10\nn_100 = (n - n_1 - n_10*10)//100\n\nif(n_1!=7 && n_10!=7 && n_100!=7):\n flag = 0\n\nif flag == 0 :\n print("NO")\nelse:\n print("YES")', 'import sys\n\nn = input()\nfor i in range(3):\n if(n[i] == "7"):\n print("YES")\n sys.exit()\n\nprint("NO")', 'import sys\n\nn = input()\nfor i in range(3):\n if(n[i] == "7"):\n printf("YES")\n sys.exit()\n\nprintf("NO")', 'n = input()\nflag = 0\n\nfor i in range(3):\n if n[i] == \'7\':\n flag = 1\n\nif flag == 0 :\n print("NO")\nelse:\n print("YES")', 'import sys\n\nn = input()\nfor i in range(3):\n if(n[i] == "7"):\n print(\'YES\')\n sys.exit()\n\nprint(\'NO\')', 'n = int(input())\nflag = 1\n\nn_1 = (n-(n//10)*10)\nn_10 = (n-(n//100)*100 - n_1)//10\nn_100 = (n - n_1 - n_10*10)//100\n\nif(n_1!=7 and n_10!=7 and n_100!=7):\n flag = 0\n\nif flag == 0 :\n print("NO")\nelse:\n print("YES")\n', 'import sys\n\nn = input()\nfor i in range(3):\n if(n[i] == "7"):\n print("Yes")\n sys.exit()\n\nprint("No")\n']
|
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s026419855', 's193538910', 's301415827', 's489049232', 's668356330', 's880256916', 's902600365', 's977941260', 's147406436']
|
[8964.0, 8984.0, 8992.0, 9064.0, 8988.0, 9016.0, 9104.0, 9140.0, 8996.0]
|
[24.0, 24.0, 25.0, 22.0, 23.0, 20.0, 21.0, 25.0, 22.0]
|
[117, 117, 212, 106, 108, 122, 106, 215, 117]
|
p02711
|
u036514535
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = input()\nif N[0] == \'7\' or N[1] == \'7\' or N[2] == \'7\':\n print("yes")\nelse:\n print("no")\n', 'N = input()\nif N[0] == \'7\' or N[1] == \'7\' or N[2] == \'7\':\n print("Yes")\nelse:\n print("No")\n']
|
['Wrong Answer', 'Accepted']
|
['s121180572', 's365358454']
|
[9100.0, 8952.0]
|
[24.0, 19.0]
|
[97, 97]
|
p02711
|
u037098269
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["n = input()\nfor i in range(3):\n if n[i] == '7':\n print('Yes')\n break\nprint('No')", "N = input()\nflag = 1\nfor i in range(3):\n if N[i] == '7':\n print('Yes')\n flag = 0\n break\n\nif flag:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s462213561', 's343054643']
|
[9096.0, 9040.0]
|
[20.0, 22.0]
|
[87, 121]
|
p02711
|
u038408819
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["n = input()\nfor ni in n:\n if ni == '7':\n print('YES')\n quit()\nprint('NO')\n", "n = input()\nfor ni in n:\n if ni == '7':\n print('Yes')\n quit()\nprint('No')\n"]
|
['Wrong Answer', 'Accepted']
|
['s383088160', 's057971403']
|
[9024.0, 8992.0]
|
[22.0, 23.0]
|
[91, 91]
|
p02711
|
u039934639
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["N = input()\n\nif N in 7:\n print('Yes')\nelse:\n print('No')", "N = input()\n\nif N in 7:\n print('Yes')\nelse:\n print('No')", "N = str(input())\n\nif '7' in N:\n print('Yes')\nelse:\n print('No')\n"]
|
['Runtime Error', 'Runtime Error', 'Accepted']
|
['s296724781', 's992378972', 's559230228']
|
[9052.0, 9032.0, 9016.0]
|
[21.0, 23.0, 23.0]
|
[58, 58, 66]
|
p02711
|
u040053163
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["n=input().count('7')\nif n>0:\n print('YES')\nelse:\n print('NO')", "n=input().count('7')\nif n>0:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s289975206', 's664521377']
|
[9092.0, 9092.0]
|
[21.0, 21.0]
|
[63, 63]
|
p02711
|
u040141413
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n=int(input())\na=n//100\nb=(n-a*100)//10\nc=n%10\nprint(a,b,c)\nif a==7 or b==7 or c==7:\n print("Yes")\nelse:\n print("No")', 'li=list(input())\nif li[0]==7 or li[1]==7 or li[2]==7:\n print("Yes")\nelse:\n print("No")', 'li=list(input())\nif li[0]=="7" or li[1]=="7" or li[2]=="7":\n print("Yes")\nelse:\n print("No")']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s250230777', 's948324459', 's197773647']
|
[9176.0, 9100.0, 8896.0]
|
[23.0, 22.0, 20.0]
|
[123, 92, 98]
|
p02711
|
u040642458
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n = input()\n\nif "7" in n:\n print("Yes")\n else:\n print("No")', 'n = input()\n\nif "7" in n:\n print("Yes")\nelse:\n print("No")\n']
|
['Runtime Error', 'Accepted']
|
['s313614145', 's005465085']
|
[8804.0, 8928.0]
|
[21.0, 20.0]
|
[64, 61]
|
p02711
|
u042497514
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = input()\ntip = "No"\nif (N[0] == 7) or (N[1] == 7) or (N[2] == 7):\n tip = "Yes"\nprint(tip)', 'N = input()\ntip = "No"\nif (N[0] == "7") or (N[1] == "7") or (N[2] == "7"):\n tip = "Yes"\nprint(tip)']
|
['Wrong Answer', 'Accepted']
|
['s259046735', 's641653685']
|
[9036.0, 9036.0]
|
[19.0, 21.0]
|
[93, 99]
|
p02711
|
u042558137
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["import sys\nN = int(input)\n\nfor i in range(len(N)):\n if N[i]==7:\n print('Yes')\n sys.exit()\n\nprint('No')", "N = input()\nF = 0\n\nfor i in range(2):\n if N[i] == '7':\n F = F + 1\n\nif F ==1 :\n print('Yes')\nelse:\n print('No')", "import sys\nN = input()\n\nfor i in range(len(N)):\n if N[i]=='7':\n print('Yes')\n sys.exit()\n\nprint('No')"]
|
['Runtime Error', 'Wrong Answer', 'Accepted']
|
['s725960348', 's762665340', 's542405201']
|
[9036.0, 9040.0, 9064.0]
|
[24.0, 20.0, 25.0]
|
[119, 126, 118]
|
p02711
|
u044419435
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["N = input().strip()\nprint('7' in N)", "N = input().strip()\n\nif '7' in N:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s649887872', 's608476623']
|
[9024.0, 9092.0]
|
[20.0, 21.0]
|
[35, 72]
|
p02711
|
u045235021
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n = input().split()\nn = [int(i) for i in n]\nf = 0\n\nfor i in n:\n if i == 7:\n f = 1\n\n if f ==1: print("Yes")\n else: print("No")', 'n = input().split()\nn = [int(i) for i in n]\nf = 0\n\nfor i in n:\n if i == 7:\n f = 1\n\nif f ==1: print("Yes")\nelse: print("No")', 'n = input()\nf = 0\n\nfor i in range(len(n)):\n if n[i] == "7":\n f = 1\n\n \nif f ==1: print("Yes")\nelse: print("No")']
|
['Wrong Answer', 'Wrong Answer', 'Accepted']
|
['s044080218', 's659132014', 's903201879']
|
[9168.0, 9164.0, 9036.0]
|
[20.0, 26.0, 22.0]
|
[127, 128, 113]
|
p02711
|
u046247133
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['N = input()\n\ns = str(N)\nif s.count("7")>0:\n\tprint(True)\nelse:\n\tprint(False)', 'a = input()\nif a.count("7")>0:\n\tprint("YES")\nelse:\n\tprint("NO")', 's = str(input())\nif s.count("7")>0:\n\tprint(True)\nelse:\n\tprint(False)', 'N = 123\n\ns = str(N)\nif s.count("7")>0:\n\tprint(True)\nelse:\n\tprint(False)', 's = str(N)\nif s.count("7")>0:\n\tprint(True)\nelse:\n\tprint(False)', 'a = input()\nif a.count("7")>0:\n\tprint("YES")\nelse:\n\tprint("NO")', 'a = input()\nif a.count("7")>0:\n\tprint("Yes")\nelse:\n\tprint("No")']
|
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s073341700', 's257382088', 's424925402', 's511681654', 's603904883', 's695739324', 's516325564']
|
[9100.0, 9036.0, 9032.0, 9096.0, 9028.0, 9032.0, 9024.0]
|
[20.0, 22.0, 21.0, 22.0, 20.0, 22.0, 21.0]
|
[75, 63, 68, 71, 62, 63, 63]
|
p02711
|
u047271634
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import re\n# input\nn = input()\n# judge\nif (re.match(\'.*7.*\', n)):\n print("YES")\nelse:\n print("NO")', 'import re\n# input\nn = input()\nif (re.match(\'.*7.*\', n)):\n print("Yes")\nelse:\n print("No")']
|
['Wrong Answer', 'Accepted']
|
['s481367094', 's135123592']
|
[9808.0, 9740.0]
|
[29.0, 26.0]
|
[103, 95]
|
p02711
|
u048546501
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["a=list(map(int, input().sprit()))\nb=True\nfor i in a\n\tif i==7:\n \tprint('Yes')\n b=False\n break;\nif b:\n print('No')\n", "a=input()\nif a[0]='7':\n\tprint('Yes')\nelif a[1]='7'\n\tprint('Yes')\nelif a[2]='7'\n\tprint('Yes')\nelse:\n print('No')", "a=input()\nans='No'\nfor i in a:\n if i==7:\n ans='Yes'\nprint(ans)", "a=input()\nans='No'\nfor i in a:\n if i=='7':\n ans='Yes'\n break\nprint(ans)"]
|
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
|
['s667572884', 's726584167', 's861349006', 's479945248']
|
[8860.0, 8812.0, 8968.0, 9032.0]
|
[20.0, 20.0, 20.0, 20.0]
|
[131, 112, 66, 78]
|
p02711
|
u048915776
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['n=input()\ns=int(n/100)\nif s==7:\n print("Yes")\n exit()\nelif n%10 == 7:\n print("Yes")\n exit()\nelif n%100>=70 and n%100<80:\n print("Yes")\n exit()\nelse:\n print("No")', 'n=int(input())\ns=int(n/100)\nif s==7:\n print("Yes")\n exit()\nelif n%10 == 7:\n print("Yes")\n exit()\nelif n%100>=70 and n%100<80:\n print("Yes")\n exit()\nelse:\n print("No")']
|
['Runtime Error', 'Accepted']
|
['s747354027', 's242269946']
|
[9116.0, 9180.0]
|
[20.0, 22.0]
|
[182, 187]
|
p02711
|
u049483705
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["a = input()\nb = str(a)\nprint(b)\nif '7' in b:\n print('Yes')\nelse:\n print('No')", "a = input()\nb = str(a)\nif '7' in b:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s225609813', 's541162295']
|
[9032.0, 9032.0]
|
[20.0, 19.0]
|
[79, 70]
|
p02711
|
u051145895
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['if 7 in N:\n print("Yes")\nelse:\n print("No")', 'x = input()\nif "7" in x:\n print(\'Yes\')\nelse:\n print(\'No\')']
|
['Runtime Error', 'Accepted']
|
['s088187178', 's712824605']
|
[9064.0, 9092.0]
|
[19.0, 21.0]
|
[45, 59]
|
p02711
|
u052244548
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
['import itertools\nimport functools\nimport math\n\ndef OK():\n N = int(input())\n\n sum = 0\n cnt = 0\n for i in range(1,N+1):\n for j in range(1,N+1):\n chk = math.gcd(i,j)\n for k in range(1,N+1):\n sum += math.gcd(chk,k)\n\n print(sum)\n\nOK()\n', "N = input()\n\nif '7' in N:\n print('Yes')\nelse:\n print('No')\n"]
|
['Wrong Answer', 'Accepted']
|
['s405397463', 's650855652']
|
[9340.0, 8900.0]
|
[2206.0, 28.0]
|
[289, 65]
|
p02711
|
u052838115
| 2,000
| 1,048,576
|
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`.
|
["N=(input())\nfor i in N:\n if '7' in i:\n print('Yes')\n break\n else:\n print('No')\n break", "N=(input())\nresult=0\nfor i in N:\n if '7' in i:\n result+=1\nif result>=1:\n print('Yes')\nelse:\n print('No')"]
|
['Wrong Answer', 'Accepted']
|
['s630093800', 's892999064']
|
[8856.0, 8960.0]
|
[22.0, 22.0]
|
[119, 120]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.