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
p03834
u777394984
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = Input()\nr1 = s[0:4]\nr2 = s[6:12]\nr3 = s[14:]\nprint("{} {} {}".format(r1, r2, r3))', 'a,b,c = map(str,input().split(","))\nprint(a + " " + b + " " + c)']
['Runtime Error', 'Accepted']
['s400519945', 's578919193']
[3064.0, 2940.0]
[17.0, 18.0]
[85, 64]
p03834
u779455925
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['print([" " if i=="," or i for i in input()])\n', 'print("".join([" " if i=="," else i for i in input()]))']
['Runtime Error', 'Accepted']
['s738103278', 's922680349']
[2940.0, 2940.0]
[17.0, 17.0]
[45, 55]
p03834
u786020649
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s=input()\n\ns[5]=' '\ns[13]=' '\n\nprint(s)", "s=input()\n\nprint(s.replace(',',' '))"]
['Runtime Error', 'Accepted']
['s292597715', 's070338583']
[8868.0, 8972.0]
[22.0, 28.0]
[39, 36]
p03834
u787562674
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['input().replace(",", " ")', 'print(input().replace(",", " "))']
['Wrong Answer', 'Accepted']
['s515925241', 's380076977']
[2940.0, 2940.0]
[17.0, 17.0]
[25, 32]
p03834
u798129018
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = input()\ns[5] = " "\ns[13] = " "\nprint(s)\n\n', 's = list(input())\ns[5] = " "\ns[13] = " "\nans = map(str,s)\n\nprint("".join(ans))']
['Runtime Error', 'Accepted']
['s046587880', 's872574528']
[2940.0, 2940.0]
[17.0, 18.0]
[45, 78]
p03834
u798316285
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a=input()\nprint(a[0:5],a[6:13],a[13:18])', 'a=input()\nprint(a[0:4],a[6:12],a[13:17])', 'a=input()\nprint(a[0:5],a[6:13],a[14:19])\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s296557856', 's312918714', 's416435080']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[40, 40, 41]
p03834
u808569469
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a = input()\nprint(a.split(","))', 's = input()\nprint(s.replace(","," "))']
['Wrong Answer', 'Accepted']
['s360014303', 's085842292']
[8936.0, 9008.0]
[31.0, 27.0]
[31, 37]
p03834
u811000506
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['K, S = map(int,input().split())\ncount = 0\nfor x in range(0,K+1,1):\n for y in range(0,K+1,1):\n z = S - x - y\n print(x,y,z)\n if x+y+z == S and z <= K and z >= 0:\n count += 1\nprint(count)', 's = str(input())\ns=s.replace(","," ")\nprint(s)']
['Runtime Error', 'Accepted']
['s721173779', 's606134707']
[3060.0, 2940.0]
[17.0, 18.0]
[199, 46]
p03834
u811967730
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['K, S = map(int, input().split())\ncount = 0\n\nfor x in range(K + 1):\n for y in range(K + 1):\n z = S - (x + y)\n if 0 <= z and z <= K:\n count += 1\n\nprint(count)\n', 's = input()\n\nprint(s.replace(",", " "))\n']
['Runtime Error', 'Accepted']
['s665224175', 's306907450']
[2940.0, 2940.0]
[17.0, 17.0]
[185, 40]
p03834
u816631826
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["\nprint(s.replace(',', ' '))", 's=str(input("enter a statment))\nz=s.replace(","," ")\nprint(z)', 'word ="happy,newyear,enjoy "\ny = word.replace(\',\' , \' \')\nprint(y)\n', 'string = input("Enter a string separated by commas: ")\nnew_string = string.replace(",", " ",string.count(","))\nprint(new_string)', 's=\' \'\ns= input ()\nb=s.replace("," ," ")\nprint (b)\n ']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s255503994', 's398796147', 's399595951', 's585089199', 's346477226']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 19.0, 18.0]
[92, 61, 66, 128, 52]
p03834
u821588465
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s= input().split(",")\nprint(*s, sep="")', 's = input().split(\',\')\nprint(*s, sep="")', 'print(*input().split(\',\'), sep = "")', 'print(*input().split(","))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s143345750', 's220439374', 's944531650', 's719116611']
[2940.0, 2940.0, 3064.0, 2940.0]
[17.0, 17.0, 18.0, 17.0]
[40, 40, 36, 26]
p03834
u821775079
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=list(input.split(","))\nprint(*s)', 's=input.split(",")\nprint(*s)', 's=input().split(",")\nprint(*s)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s171557804', 's230841907', 's846424574']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0]
[34, 28, 30]
p03834
u822738981
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['# -*- coding: utf-8 -*-\n\nk, s = map(int, input().split())\n\nans = 0\n\nfor i in range(k+1):\n for j in range(k+1):\n k2 = s - j - i\n if 0 <= k2 <=k:\n ans += 1\n\n \n # if k2 > k or k2 < 0:\n # continue\n \n # ans += 1\n\nprint(ans)\n', "# -*- coding: utf-8 -*-\n\ns = input()\n\nprint(s.replace(',', ' '))"]
['Runtime Error', 'Accepted']
['s066205951', 's944035340']
[2940.0, 2940.0]
[17.0, 17.0]
[325, 64]
p03834
u835575472
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = input();\ns.replace(",", " ")\nprint(s)', 's = input()\nprint(s.replace(",", " "))']
['Wrong Answer', 'Accepted']
['s393594815', 's212387228']
[9052.0, 8976.0]
[24.0, 29.0]
[41, 38]
p03834
u842028864
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['print(*list[input().split(",")])', 'a,b.c = input().split(",")\nprint(a,b,c)', 'print(*list(input().split(",")))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s259852955', 's595154243', 's398489300']
[9076.0, 3064.0, 9012.0]
[24.0, 17.0, 31.0]
[32, 39, 32]
p03834
u842696304
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['happy,newyear,enjoy', "print(input().replace(',', ' '))"]
['Runtime Error', 'Accepted']
['s875121191', 's755291496']
[2940.0, 2940.0]
[17.0, 17.0]
[19, 32]
p03834
u845620905
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a = input().split(\',\')\nans = ""\nfor i in a:\n ans += a[i] + " "\nans -= " "\nprint(ans)', 'a = input().replace(",", " ")\nprint(a)']
['Runtime Error', 'Accepted']
['s805591811', 's840423538']
[2940.0, 2940.0]
[18.0, 18.0]
[85, 38]
p03834
u857330600
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s=list(str(input()))\ns[5]=' '\ns[13]=' '\nprint('',join(s))", "s=list(str(input()))\ns[5]=' '\ns[13]=' '\nprint(''.join(s))"]
['Runtime Error', 'Accepted']
['s229439470', 's269601060']
[2940.0, 2940.0]
[17.0, 17.0]
[57, 57]
p03834
u862296914
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['print(input().replace(/,/g," "))', 'print(input().replace(","," "))']
['Runtime Error', 'Accepted']
['s455109765', 's669977528']
[2940.0, 2940.0]
[18.0, 17.0]
[32, 31]
p03834
u863370423
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=str()\nz=s.replace(","," ")\nprint(z)\n"""my name is mohamed"""', 'n=str(input())\nfor i in n:\n if i==",":\n n=n.replace(","," ")\nprint(n)']
['Wrong Answer', 'Accepted']
['s537687485', 's132536619']
[2940.0, 2940.0]
[17.0, 17.0]
[62, 79]
p03834
u863442865
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['k, s = list(map(int, input().split()))\ncnt = 0\nfor i in range(k+1):\n for j in range(k+1):\n for k in range(k+1):\n total = i+j+k\n if total==s:\n cnt += 1\nprint(cnt)', "s = input()\nprint(s.replace(',', ' '))"]
['Runtime Error', 'Accepted']
['s030054381', 's038986042']
[2940.0, 2940.0]
[17.0, 19.0]
[208, 38]
p03834
u864667985
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["print(input().replace(',',''))", "print(input().replace(',',' '))"]
['Wrong Answer', 'Accepted']
['s873731034', 's784908722']
[2940.0, 2940.0]
[18.0, 18.0]
[30, 31]
p03834
u869265610
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c=input().split()\nprint(a,b,c,="")', 'a,b,c=input().split(",")\nprint(a,b,c)']
['Runtime Error', 'Accepted']
['s230873216', 's381667586']
[2940.0, 2940.0]
[18.0, 17.0]
[38, 37]
p03834
u869728296
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a=input().strip().split(",")\n\nprint(a)\n', 'a=input().strip().split(",")\n\nprint(a[0]+" "+a[1]+" "+a[2])\n']
['Wrong Answer', 'Accepted']
['s435170191', 's960953654']
[2940.0, 3064.0]
[19.0, 18.0]
[39, 60]
p03834
u871596687
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = list(str(input()))\n\nprint(s[0]+s[1]+s[2]+s[3]+s[4])+" "+s[6]+s[7]+s[8]+s[9]+s[10]+s[11]+s[12]+" "+s[14]+s[15]+s[16]+s[17]+s[18])\n\n\n\n', 's = list(str(input()))\n\nprint(s[0]+s[1]+s[2]+s[3]+s[4]+" "+s[6]+s[7]+s[8]+s[9]+s[10]+s[11]+s[12]+" "+s[14]+s[15]+s[16]+s[17]+s[18])\n\n\n\n']
['Runtime Error', 'Accepted']
['s307632841', 's781285574']
[3064.0, 2940.0]
[18.0, 17.0]
[136, 135]
p03834
u875600867
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['print(input().replace("," " "))', "print(input().replace(',', ' '))\n"]
['Runtime Error', 'Accepted']
['s922696407', 's443457988']
[2940.0, 2940.0]
[18.0, 17.0]
[31, 33]
p03834
u881100099
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c=input().split(",")\nprint("a","b","c")', 'a,b,c=input().split(",")\nprint(a,b,c)']
['Wrong Answer', 'Accepted']
['s544338476', 's613823410']
[2940.0, 2940.0]
[17.0, 17.0]
[43, 37]
p03834
u884795391
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = input()\nprint(s.split(',')", 's = input()\nprint(*s.split(","))']
['Runtime Error', 'Accepted']
['s191556990', 's074820743']
[2940.0, 2940.0]
[17.0, 17.0]
[30, 32]
p03834
u886902015
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=input()\nprint(s.split(","))', 's=input()\nprint(s.split(,))', 's=input()\nprint(s.replace(","," "))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s212226409', 's337437136', 's019112211']
[9060.0, 9004.0, 8980.0]
[26.0, 23.0, 28.0]
[29, 27, 35]
p03834
u895040371
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['A,B,C =map(str, input().split(,))\nprint(A,B,C)', 'a, b, c = input().split(",")\nprint(a, b, c)']
['Runtime Error', 'Accepted']
['s618850184', 's270608043']
[2940.0, 2940.0]
[17.0, 18.0]
[46, 43]
p03834
u896741788
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["a,s,d=input(),split(',')\nprint(a,s,d)", "a,s,d=input().split(',')\nprint(a,s,d)"]
['Runtime Error', 'Accepted']
['s898038751', 's858929024']
[2940.0, 2940.0]
[17.0, 17.0]
[37, 37]
p03834
u897436032
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['input_ = inpur().split(",")\nprint(" ".join(str for i in input))', 'inp = input().split(",")\n\nprint(" ".join(inp))']
['Runtime Error', 'Accepted']
['s647908422', 's798727682']
[2940.0, 2940.0]
[17.0, 17.0]
[63, 46]
p03834
u901598613
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c=input().split()\nprint(a+" "+b+" "+c)', 'a=input()\nl=a.split(",")\nprint(l[0]+" "+l[1]+" "+l[2])']
['Runtime Error', 'Accepted']
['s165979525', 's932033904']
[2940.0, 2940.0]
[17.0, 17.0]
[42, 54]
p03834
u902242214
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['x, y ,z = input().split(,)\nprint(x, y, z)', 'a, b, c = input().split(,)\nprint(a, b, c)', 'a, b, c = input().split(",")\nprint(a, b, c)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s046137213', 's099493705', 's503838911']
[8824.0, 8816.0, 8856.0]
[25.0, 25.0, 29.0]
[41, 41, 43]
p03834
u904995051
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a = input()\nb = a.split(",")\nprint(b)', 's = input().split(",")\nprint(*s, sep=" ")']
['Wrong Answer', 'Accepted']
['s289638603', 's795515263']
[2940.0, 8960.0]
[17.0, 29.0]
[37, 41]
p03834
u905582793
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['k,s=map(int,input().split())\nans = 0\nfor i in range(k+1):\n if k<=s-i<=2*k:\n ans+= s-i+1\n elif 0<=s-i<=k:\n ans+= k*2-s+1\nprint(ans)', 'k,s=map(int,input().split())\nans = 0\nfor i in range(k+1):\n if k <=s-i<=2*k:\n ans+= s-i+1\n elif 0<=s-i<=k:\n ans+= k*2-s+1\nprint(ans)', 'print(input().replace(","," "))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s220144480', 's665082650', 's894522704']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[142, 139, 31]
p03834
u911153222
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = [input().split()]\nprint('{} {} {}'.format(s))\n", "print(*input().split(','))"]
['Runtime Error', 'Accepted']
['s407288819', 's795184309']
[3060.0, 2940.0]
[19.0, 17.0]
[50, 26]
p03834
u911575040
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["a,b,c=input().split(' ')\nif b=='+':\n print(int(a)+int(c))\nelse:\n print(int(a)-int(c))\n", "a,b,c=map(str,input().split(','))\nprint(a,b,c)\n"]
['Runtime Error', 'Accepted']
['s323289958', 's672745022']
[2940.0, 2940.0]
[17.0, 18.0]
[92, 47]
p03834
u919521780
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = input()\ns.replace(',', ' ')\nprint(s)", "s = input()\ns = s.replace(',', ' ')\nprint(s)"]
['Wrong Answer', 'Accepted']
['s334611562', 's750121658']
[2940.0, 2940.0]
[17.0, 17.0]
[40, 44]
p03834
u920299620
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=input()\nprint(f"{} {} {}".format( s[0,5], s[6,13],s[14,19] ) )', 's=input()\nprint("{} {} {}".format( s[0,5], s[6,13],s[14,19] ) )', 's=list(input()\nprint("{} {} {}".format( s[0,5], s[6,13],s[14,19] ) )', 's=input()\nprint("{} {} {}".format( s[0:5], s[6:13],s[14:19] ) )']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s240987921', 's475149967', 's648508570', 's707836351']
[2940.0, 3060.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0, 17.0]
[64, 63, 68, 63]
p03834
u920438243
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['k,s = map(int,input().split())\ncount = 0\nfor i in range(k+1):\n for j in range(k+1):\n if s-i-j <= k:\n count += 1\nprint(count)\n', 'k,s = map(int,input().split())\ncount = 0\nfor i in range(k+1):\n for j in range(k+1):\n if s-(i+j) <= k and s-(i+j) >= 0:\n count += 1\nprint(count)\n', 'line = input()\nprint(line.replace(","," "))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s535704241', 's867557522', 's770333849']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0]
[146, 165, 44]
p03834
u921632705
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['x, y, z = input().split\nprint(x, y, z)', "x,y,z = int().split(',')\nprint(x,y,z)", "x,y,z = input().split(',')\nprint(x,y,z)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s267864881', 's712544202', 's183889486']
[9012.0, 9004.0, 8980.0]
[24.0, 26.0, 26.0]
[38, 37, 39]
p03834
u921773161
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = input()\nfor i in range(len(s)):\n if s[i]==',':\n s[i]==' '\nprint(s)", "s = list(input())\nfor i in range(len(s)):\n if s[i]==',':\n s[i]=' '\nprint(''.join(s))"]
['Wrong Answer', 'Accepted']
['s818406253', 's641035810']
[2940.0, 2940.0]
[17.0, 17.0]
[74, 88]
p03834
u923659712
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a = str(input())\n\na.replace(","," ")\n\nprint(a)', 'a = str(input())\n\na=a.replace(","," ")\n\nprint(a)']
['Wrong Answer', 'Accepted']
['s174470983', 's761403337']
[2940.0, 2940.0]
[17.0, 17.0]
[46, 48]
p03834
u932465688
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = input()\ns.replace(',',' ')", "s = input()\np = s.replace(',',' ')\nprint(p)"]
['Wrong Answer', 'Accepted']
['s064116196', 's744319480']
[2940.0, 2940.0]
[17.0, 17.0]
[30, 43]
p03834
u936985471
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c=input().split()\nprint(a,b,c)', 'print(input().split())', 'a,b,c=input().split(",")\nprint(a,b,c)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s818910217', 's955580158', 's478630667']
[2940.0, 2940.0, 2940.0]
[17.0, 17.0, 17.0]
[34, 22, 37]
p03834
u945419374
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=input()\nprint(s.replace(",","/"))\n', 's=input()\nprint(s.replace(","," "))\n']
['Wrong Answer', 'Accepted']
['s762372904', 's970597018']
[2940.0, 2940.0]
[17.0, 17.0]
[36, 36]
p03834
u953486781
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s = input()\ns_list = [s.strip() for x in s.split(',')]\nprint(' '.join(s_list))", "s = input()\ns_list = [x.strip() for x in s.split(',')]\nprint(' '.join(s_list))"]
['Wrong Answer', 'Accepted']
['s902518940', 's331358395']
[2940.0, 2940.0]
[17.0, 17.0]
[78, 78]
p03834
u957872856
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c = input().split(,)\nprint(a+" "+b+" "+c)', 'a,b,c = input().split(",")\nprint(a+" "+b+" "+c)']
['Runtime Error', 'Accepted']
['s576639775', 's584804062']
[2940.0, 2940.0]
[17.0, 17.0]
[45, 47]
p03834
u959759457
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s,t,u=map(int,input().split(''))\nprint(s,t,u)", "s,t,u=map(int,input().split(','))\nprint(s,t,u)", "s,t,u=map(str,input().split(','))\nprint(s,t,u)"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s106238431', 's319677785', 's913372310']
[2940.0, 2940.0, 2940.0]
[18.0, 17.0, 17.0]
[45, 46, 46]
p03834
u967835038
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['K, S = list(map(int, input().split()))\n\na = 0\nfor i in range(K + 1):\n r = S - i\n if i <= S and r <= K * 2:\n t = (r + 1) - max(0, r - K) * 2\n a += t\n\nprint(a)\n', "print(input().replace(',',' '))"]
['Runtime Error', 'Accepted']
['s493327543', 's534499966']
[2940.0, 2940.0]
[17.0, 17.0]
[178, 31]
p03834
u969190727
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a,b,c=input()split(",")\nprint(a,b,c)', 'a,b,c=input().split(",")\nprint(a,b,c)\n']
['Runtime Error', 'Accepted']
['s189715906', 's201688111']
[2940.0, 2940.0]
[17.0, 17.0]
[36, 38]
p03834
u970082363
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['list = list(map(str,input()))\nlist[5] = " "\nlist[13] = " "\nprint(list)', 'list = list(map(str,input()))\nlist[5] = " "\nlist[13] = " "\nprint("".join(list))\n']
['Wrong Answer', 'Accepted']
['s023546062', 's608307526']
[2940.0, 2940.0]
[17.0, 18.0]
[70, 80]
p03834
u970449052
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
["s=input()\nprint(s.replace(',',' ')", "s=input()\nprint(s.replace(',',' '))"]
['Runtime Error', 'Accepted']
['s347964569', 's155848990']
[2940.0, 3068.0]
[17.0, 17.0]
[34, 35]
p03834
u971091945
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = input()\nprint(s[:5]+" "+s[7:14]+" "+s[16:])', "s = input()\nl = s.split(',')\nans = ' '.join(l)\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s242956658', 's906389969']
[2940.0, 2940.0]
[19.0, 17.0]
[47, 57]
p03834
u972892985
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a, b, c = input().split(",")\nprint(a+b+c)', 'a, b, c = input().split(",")\nprint(a, b, c)']
['Wrong Answer', 'Accepted']
['s705503666', 's528891076']
[2940.0, 2940.0]
[17.0, 18.0]
[41, 43]
p03834
u974935538
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s=str("haiku,atcoder,tasks")\nprint(s.replace(",", " "))', 't=str(s)\nprint(t.replace(",", " "))', "s = input()\nprint(s.replace(',', ' '))"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s131363156', 's865795900', 's749801062']
[2940.0, 2940.0, 2940.0]
[18.0, 19.0, 18.0]
[55, 35, 38]
p03834
u975016227
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['k, s = list(map(int, input().split()))\nnum = 0\n\nfor x in range(k+1):\n for y in range(k+1):\n if s-k <= x+y <= s:\n num += 1\n\nprint(num)\n', "s = input()\nprint(s.replace(',', ' '))\n"]
['Runtime Error', 'Accepted']
['s737338807', 's614409300']
[2940.0, 2940.0]
[18.0, 18.0]
[143, 39]
p03834
u975676823
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a, b, c = input().split(sep = ", ")\n\nprint(a + " " + b + " " + c)\n', 'a, b, c = input().split(sep = ",")\n\nprint(a + b + c)\n\n', 'a, b, c = input().split(sep = ",")\nprint(a + b + c)\n', 'a, b, c = input().split(sep = ", ")\nif(len(a) == 7):\n print(b.lower() + " " + a.lower() + " " + c.lower())\nelif(len(b) == 7):\n print(a.lower() + " " + b.lower() + " " + c.lower())\nelif(len(c) == 7):\n print(a.lower() + " " + c.lower() + " " + b.lower*(()\n', 'a, b, c = input().split(sep = ",")\n \nprint(a, b, c)\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s225018985', 's726825141', 's854347235', 's887148738', 's325309214']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 18.0, 17.0, 18.0, 17.0]
[66, 54, 52, 264, 52]
p03834
u975719989
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['s = input()\ns = s.replace(",", "")\n\nprint(s)', "s = input()\ns = s.replace(',', ' ')\nprint(s)"]
['Wrong Answer', 'Accepted']
['s893868026', 's577110229']
[2940.0, 2940.0]
[17.0, 17.0]
[44, 44]
p03834
u978494963
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['import re\nre.sub(","," ",str(input()))', 'import re\nprint(re.sub(","," ",str(input())))']
['Wrong Answer', 'Accepted']
['s783695712', 's213026028']
[3188.0, 3188.0]
[19.0, 19.0]
[38, 45]
p03834
u979078704
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['a, b, c = input.split(",")\nprint(a,b,c)', "a = input()\nprint(a.replace(',' , ' ')", "a = input()\nprint(a.replace(',' , ' ')", 'a, b, c = input.split(",")\nprint(a, b, c)', 'print(*input.split(",")', "s = input()\nprint(s.replace(',', ' '))\na = input()\nprint(a.replace(',' , ' ')", "print(*input().split(',')", "a = input()\nprint(a.replace(',' , ' '))"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s113579100', 's280795525', 's517390147', 's704453346', 's707837305', 's784544041', 's869248919', 's822823906']
[2940.0, 3060.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 20.0, 17.0, 17.0, 17.0, 17.0, 17.0, 17.0]
[39, 38, 38, 41, 23, 77, 25, 39]
p03834
u998082063
2,000
262,144
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform the conversion for him.
['happy,newyear,enjoy', 'a = input()\n\nb = a.replace(",", " ")\n\nprint(b)']
['Runtime Error', 'Accepted']
['s918832565', 's008683005']
[2940.0, 2940.0]
[17.0, 17.0]
[19, 46]
p03837
u021337285
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import sys\nfrom scipy.sparse.csgraph import dijkstra\n\ninput = sys.stdin.readline\nN, M = map(int, input().split())\n\ngraph = [[0 if i == j else float("inf") for i in range(N)] for j in range(N)]\nfor i in range(M):\n ai, bi, ci = map(int, input().split())\n graph[ai - 1][bi - 1] = ci\n graph[bi - 1][ai - 1] = ci\n\ndist1 = dijkstra(graph, directed=False)\nprint(graph)\nprint(dist1)\n\ncnt = 0\nfor i in range(N):\n for j in range(N):\n used = False\n if i > j:\n continue\n for k in range(N):\n if graph[i][j] + dist1[k][i] == dist1[i][j]:\n used = True\n break\n if not used and graph[i][j] == "inf":\n cnt += 1\nprint(cnt)\n', 'import sys\nfrom scipy.sparse.csgraph import dijkstra\n\ninput = sys.stdin.readline\nN, M = map(int, input().split())\n\ngraph = [[0 if i == j else float("inf") for i in range(N)] for j in range(N)]\nfor i in range(M):\n ai, bi, ci = map(int, input().split())\n graph[ai - 1][bi - 1] = ci\n graph[bi - 1][ai - 1] = ci\n\ndist1 = dijkstra(graph, directed=False)\nprint(graph)\nprint(dist1)\n\ncnt = 0\nfor i in range(N):\n for j in range(N):\n used = False\n if i > j:\n continue\n for k in range(N):\n if graph[i][j] + dist1[k][i] == dist1[i][j]:\n used = True\n break\n if not used and graph[i][j] != float("inf"):\n cnt += 1\nprint(cnt)\n', 'import sys\nfrom scipy.sparse.csgraph import dijkstra\n\ninput = sys.stdin.readline\nN, M = map(int, input().split())\n\ngraph = [[0 if i == j else float("inf") for i in range(N)] for j in range(N)]\nfor i in range(M):\n ai, bi, ci = map(int, input().split())\n graph[ai - 1][bi - 1] = ci\n graph[bi - 1][ai - 1] = ci\n\ndist = dijkstra(graph, directed=False)\n\ncnt = 0\nfor i in range(N):\n for j in range(N):\n used = False\n if i > j:\n continue\n for k in range(N):\n if graph[i][j] + dist[k][i] == dist[i][j]:\n used = True\n break\n if not used and graph[i][j] != float("inf"):\n cnt += 1\nprint(cnt)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s678129334', 's970392260', 's226409867']
[17436.0, 18640.0, 18296.0]
[936.0, 901.0, 897.0]
[707, 714, 685]
p03837
u021548497
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import sys\ninput = sys.stdin.readline\n\ndef main():\n n, m = map(int, input().split())\n road = [[100000]*n for _ in range(n)]\n count = [[-1]*n for i in range(n)]\n for _ in range(m):\n a, b, c = map(int, input().split())\n road[a-1][b-1] = c\n road[b-1][a-1] = c\n count[a-1][b-1] = 0\n count[b-1][a-1] = 0\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if road[i][k]+road[k][j] < road[i][j]:\n if count[i][j] == 0:\n count[i][j] = 1\n road[i][j] = road[i][k]+road[k][j]\n print(count)\n ans = 0\n for i in range(n):\n ans += count[i].count(1)\n print(ans//2)\nif __name__ == "__main__":\n main()', 'import sys\ninput = sys.stdin.readline\n\ndef main():\n n, m = map(int, input().split())\n road = [[100000]*n for _ in range(n)]\n count = [[-1]*n for i in range(n)]\n for _ in range(m):\n a, b, c = map(int, input().split())\n road[a-1][b-1] = c\n road[b-1][a-1] = c\n count[a-1][b-1] = 0\n count[b-1][a-1] = 0\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if road[i][k]+road[k][j] < road[i][j]:\n if count[i][j] == 0:\n count[i][j] = 1\n road[i][j] = road[i][k]+road[k][j]\n ans = 0\n for i in range(n):\n ans += count[i].count(1)\n print(ans//2)\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s205261691', 's233010164']
[9092.0, 9420.0]
[166.0, 165.0]
[664, 649]
p03837
u075012704
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["N, M = map(int, input().split())\nG = [[float('inf')]*N for i in range(N)]\nG2 = [[float('inf')]*N for i in range(N)]\nfor i in range(M):\n a, b, c = map(int, input().split())\n G[a-1][b-1] = c\n G[b-1][a-1] = c\n G2[a-1][b-1] = c\n G2[b-1][a-1] = c\n\nfor i in range(N):\n for j in range(N):\n for k in range(N):\n if G[i][j] > G[i][k] + G[k][j]:\n G[i][j] = G[i][k] + G[k][j]\n\ncnt = 0\nfor i in range(N):\n for j in range(N):\n for k in range(N):\n if G[i][j] != G2[i][j]:\n cnt += 1\n\nprint(M - cnt//2)\n", "from copy import deepcopy\nN, M = map(int, input().split())\nG = [[float('inf')] * N for i in range(N)]\nfor i in range(M):\n a, b, c = map(int, input().split())\n a, b = a - 1, b - 1\n G[a][b] = c\n G[b][a] = c\n\n\nShortest = deepcopy(G)\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n Shortest[i][j] = min(Shortest[i][j], Shortest[i][k] + Shortest[k][j])\n\n\nans = 0\nfor i in range(N):\n for j in range(N):\n if G[i][j] == float('inf'):\n continue\n if G[i][j] != Shortest[i][j]:\n ans += 1\n\nprint(ans // 2)\n"]
['Wrong Answer', 'Accepted']
['s550913992', 's159784240']
[3468.0, 3992.0]
[680.0, 673.0]
[573, 578]
p03837
u127499732
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import heapq\n\n\ndef dijkstra(n, s, g):\n h = [(0, s)]\n heapq.heapify(h)\n cost = [float("Inf")] * (n + 1) \n cost[s] = 0\n\n while h:\n c, v = heapq.heappop(h)\n if c > cost[v]:\n continue\n for d, u in g[v]:\n d_s_u = d + cost[v]\n if d_s_u < cost[u]:\n cost[u] = d_s_u\n heapq.heappush(h, (d_s_u, u))\n\n return cost\n\n\ndef main():\n n, m, *abc = map(int, open(0).read().split())\n g = [[] for _ in range(n + 1)]\n\n for a, b, c in zip(*[iter(abc)] * 3):\n g[a].append([c, b])\n g[b].append([c, a])\n\n ans = 0\n checkd = [[False] * (n + 1) for _ in range(n + 1)]\n for i in range(1, n + 1):\n cost = dijkstra(n, i, g)\n for j, k in g[i]:\n if checkd[i][j]:\n continue\n if j > cost[k]:\n ans += 1\n checkd[i][j] = True\n checkd[j][i] = True\n \n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n', 'import heapq\n\n\ndef dijkstra(n, s, g):\n h = [(0, s)]\n heapq.heapify(h)\n cost = [float("Inf")] * (n + 1) \n cost[s] = 0\n\n while h:\n c, v = heapq.heappop(h)\n if c > cost[v]:\n continue\n for d, u in g[v]:\n d_s_u = d + cost[v]\n if d_s_u < cost[u]:\n cost[u] = d_s_u\n heapq.heappush(h, (d_s_u, u))\n\n return cost\n\n\ndef main():\n n, m, *abc = map(int, open(0).read().split())\n g = [[] for _ in range(n + 1)]\n\n for a, b, c in zip(*[iter(abc)] * 3):\n g[a].append([c, b])\n g[b].append([c, a])\n\n ans = 0\n checked = [[False] * (n + 1) for _ in range(n + 1)]\n for i in range(1, n + 1):\n cost = dijkstra(n, i, g)\n for j, k in g[i]:\n if checked[i][k]:\n continue\n if j > cost[k]:\n ans += 1\n\n checked[i][k] = True\n checked[k][i] = True\n\n print(ans)\n\n\nif __name__ == \'__main__\':\n main()\n']
['Runtime Error', 'Accepted']
['s604703279', 's622514059']
[9400.0, 9328.0]
[31.0, 64.0]
[1006, 1007]
p03837
u139112865
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['#051_D\nfrom heapq import heappop, heappush\ninf = 10 ** 10\nd = [[inf for _ in range(n)] for _ in range(n)]\nfor i in range(n):\n d[i][i] = 0\nn, m = map(int, input().split())\nedges = []\nfor _ in range(m):\n a, b, c = map(int, input().split())\n d[a-1][b-1] = c\n d[b-1][a-1] = c\n edges.append((a-1, b-1))\n\ndef warshall_floyd(d):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \nwarshall_floyd(d)\n\nans = 0\nfor u, v in edges:\n for i in range(n):\n if i == u or i == v:\n continue\n if d[u][i] + d[i][v] == d[u][v]:\n ans += 1\n break\n\nprint(ans)', '#051_D\ninf = 10 ** 10\nn, m = map(int, input().split())\nd = [[inf for _ in range(n)] for _ in range(n)]\nfor i in range(n):\n d[i][i] = 0\nedges = []\nfor _ in range(m):\n a, b, c = map(int, input().split())\n d[a-1][b-1] = c\n d[b-1][a-1] = c\n edges.append((a-1, b-1, c))\n\ndef warshall_floyd(d):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \nwarshall_floyd(d)\n\nans = m\nfor u, v, c in edges:\n flg = False\n for i in range(n):\n if d[i][v] + c == d[i][u]:\n flg = True\n \n if flg:\n ans -= 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s072272859', 's601148971']
[3192.0, 3444.0]
[18.0, 485.0]
[703, 651]
p03837
u167751176
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["def main():\n\tN, M = map(int, input().split())\n\tpoints = [[] for _ in range(N+1)]\n\tfor i in range(1, M+1):\n\t\ta, b, c = map(int, input().split())\n\t\tpoints[a].append([b, c, i])\n\t\tpoints[b].append([a, c, i])\n\tuse = set()\n\tdef dijksta(start):\n\t\tis_visited = [False]*(N+1)\n\t\tis_visited[0] = True\n\t\tis_visited[start] = True\n\t\tstack = list(points[start])\n\t\tedge = 0\n\t\twhile stack:\n\t\t\tedge += 1\n\t\t\tstack.sort(key=lambda x: x[1])\n\t\t\tuse_edge = stack.pop()\n\t\t\tcur = use_edge[0]\n\t\t\tdist = use_edge[1]\n\t\t\tuse.add(use_edge[2])\n\t\t\tis_visited[cur] = True\n\t\t\tif all(is_visited):\n\t\t\t\treturn edge\n\t\t\tadd_stack = list(points[cur])\n\t\t\tremoves = []\n\t\t\tfor i, pair in enumerate(add_stack):\n\t\t\t\tif is_visited[pair[0]]:\n\t\t\t\t\tremoves.append(i)\n\t\t\t\t\tcontinue\n\t\t\t\tadd_stack[i][1] += dist\n\t\t\tremoves.reverse()\n\t\t\tfor i in removes:\n\t\t\t\tadd_stack.pop(i)\n\t\t\tstack.extend(add_stack)\n\tfor i in range(1, M+1):\n\t\tdijksta(i)\n\tans = M - len(use)\n\tprint(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n\tN, M = map(int, input().split())\n\tpoints = [[] for _ in range(N+1)]\n\tfor i in range(1, M+1):\n\t\ta, b, c = map(int, input().split())\n\t\tpoints[a].append([b, c, i])\n\t\tpoints[b].append([a, c, i])\n\tuse = set()\n\tdef dijksta(start):\n\t\tis_visited = [False]*(N+1)\n\t\tis_visited[0] = True\n\t\tis_visited[start] = True\n\t\tstack = list(points[start])\n\t\twhile stack:\n\t\t\tstack.sort(key=lambda x: x[1])\n\t\t\tuse_edge = stack.pop()\n\t\t\tcur = use_edge[0]\n\t\t\tdist = use_edge[1]\n\t\t\tuse.add(use_edge[2])\n\t\t\tis_visited[cur] = True\n\t\t\tif all(is_visited):\n\t\t\t\tbreak\n\t\t\tadd_stack = list(points[cur])\n\t\t\tremoves = []\n\t\t\tfor i, pair in enumerate(add_stack):\n\t\t\t\tif is_visited[pair[0]]:\n\t\t\t\t\tremoves.append(i)\n\t\t\t\t\tcontinue\n\t\t\t\tadd_stack[i][1] += dist\n\t\t\tremoves.reverse()\n\t\t\tfor i in removes:\n\t\t\t\tadd_stack.pop(i)\n\t\t\tstack.extend(add_stack)\n\tfor i in range(1, M+1):\n\t\tdijksta(i)\n\tans = M - len(use)\n\tprint(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n\tINF = 10**9+7\n\tN, M = map(int, input().split())\n\tdist = [[INF for _ in range(N+1)] for _ in range(N+1)]\n\tfor i in range(1, N+1):\n\t\tfor j in range(1, N+1):\n\t\t\tif i == j:\n\t\t\t\tdist[i][j] = 0\n\ta, b, c = [0]*M, [0]*M, [0]*M\n\tfor i in range(M):\n\t\ta[i], b[i], c[i] = map(int, input().split())\n\t\tdist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i])\n\t\tdist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i])\n\tfor k in range(1, N+1):\n\t\tfor i in range(1, N+1):\n\t\t\tfor j in range(1, N+1):\n\t\t\t\tdist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])\n\tans = M\n\tfor i in range(M):\n\t\tshrotest = False\n\t\tfor j in range(1, N+1):\n\t\t\tif dist[j][a[i]]+c[i] == dist[j][b[i]]:\n\t\t\t\tshrotest = True\n\t\tif shrotest:\n\t\t\tans -= 1\n\tprint(ans)\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s241414194', 's543285252', 's331096398']
[3828.0, 3828.0, 3428.0]
[1099.0, 1079.0, 427.0]
[958, 928, 745]
p03837
u169350228
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\nfrom scipy.sparse.csgraph import dijkstra\nfrom scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n,m = map(int,ipt().split())\n cos = []\n row = []\n col = []\n for _ in range(m):\n a,b,c = map(int,ipt().split())\n row.append(a-1)\n col.append(b-1)\n cos.append(c)\n cos.append(c)\n csr = csr_matrix((cos,(row,col)),shape=(n,n))\n d = dijkstra(csr,directed=False)\n ans = 0\n for i in range(m):\n csr = csr_matrix((cos[:i:]+cos[i+1::],(row[:i:]+row[i+1::],col[:i:]+col[i+1::])),shape=(n,n))\n di = dijkstra(csr)\n if (di == d).all():\n ans += 1\n print(ans)\n return\n\nif __name__ == '__main__':\n main()\n", "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\nfrom scipy.sparse.csgraph import dijkstra\nfrom scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n,m = map(int,ipt().split())\n cos = []\n row = []\n col = []\n for _ in range(m):\n a,b,c = map(int,ipt().split())\n row.append(a-1)\n col.append(b-1)\n cos.append(c)\n csr = csr_matrix((cos,(row,col)),shape=(n,n))\n d = dijkstra(csr,directed=False)\n ans = 0\n for i in range(m):\n rwi = row[i]\n cli = col[i]\n csi = cos[i]\n dri = d[rwi]\n dci = d[cli]\n for j in range(n):\n if dri[j] + csi == dci[j]:\n break\n if j == n-1:\n ans += 1\n print(ans)\n return\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s534380098', 's245683842']
[17408.0, 15916.0]
[249.0, 301.0]
[875, 918]
p03837
u169650582
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['N,M=map(int,input().split())\nIslands=[[] for i in range(N)]\nEdge=[]\nS=0\nfor i in range(M):\n a,b,c=map(int,input().split())\n Islands[a-1].append([b-1,c])\n Islands[b-1].append([a-1,c])\n Edge.append([a-1,b-1])\nfor m in range(M):\n a=Edge[m][0]\n b=Edge[m][1]\n for i in Islands[a]:\n if i[0]==b:\n c_m=i[1]\n List=[[a,-1]]\n for l in List:\n print(List)\n c=(-1)*(l[-1]+1)\n if l[-2]==b:\n if c_m>c:\n S+=1\n break\n else: \n for n in Islands[l[-2]]:\n if n[0] in l:\n pass\n else:\n c+=n[1]\n List.append(l[0:-1]+[n[0],(-1)*(c+1)])\n \nprint(S) ', 'N,M=map(int,input().split())\nIslands=[[] for i in range(N)]\nEdge=[]\nS=0\nfor i in range(M):\n a,b,c=map(int,input().split())\n Islands[a-1].append([b-1,c])\n Islands[b-1].append([a-1,c])\n Edge.append([a-1,b-1])\nfor m in range(M):\n a=Edge[m][0]\n b=Edge[m][1]\n for i in Islands[a]:\n if i[0]==b:\n c_m=i[1]\n List=[[a,0]]\n for l in List:\n print(m,List)\n c_base=l[-1]\n c=c_base\n if l[-2]==b:\n if c_m>c:\n S+=1\n break\n else: \n for n in Islands[l[-2]]:\n if n[0] in l[0:-1]:\n pass\n else:\n c+=n[1]\n List.append(l[0:-1]+[n[0],c]) \n c=c_base\nprint(S-1) \n ', 'N,M=map(int,input().split())\nIslands=[[] for i in range(N)]\nEdge=[]\nS=0\nfor i in range(M):\n a,b,c=map(int,input().split())\n Islands[a-1].append([b-1,c])\n Islands[b-1].append([a-1,c])\n Edge.append([a-1,b-1,c])\nfor m in range(M):\n a=Edge[m][0]\n b=Edge[m][1]\n c_m=Edge[m][2]\n List=[[a,0]]\n for l in List:\n c_base=l[-1]\n c=c_base\n if l[-2]==b:\n if c_m>c:\n S+=1\n break\n else: \n for n in Islands[l[-2]]:\n if n[0] in l[0:-1]:\n pass\n else:\n c+=n[1]\n List.append(l[0:-1]+[n[0],c]) \n c=c_base\nprint(S-1) ', 'N,M=map(int,input().split())\nIslands=[[10**9]*N for i in range(N)]\nEdge=[]\nS=0\nfor i in range(M):\n a,b,c=map(int,input().split())\n Islands[a-1][b-1]=c\n Islands[b-1][a-1]=c\n Edge.append([a-1,b-1,c])\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n Islands[i][j]=min(Islands[i][j],Islands[i][k]+Islands[k][j])\n\nans=0\nfor a,b,c in Edge:\n if Islands[a][b]!=c:\n ans+=1\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s442915266', 's455952485', 's756679465', 's870199855']
[106996.0, 105780.0, 280220.0, 3444.0]
[2104.0, 2104.0, 2122.0, 554.0]
[636, 660, 602, 402]
p03837
u180058306
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['\nN, M = map(int, input().split())\n\n\ndic_edge_dist = {(i, j) : float("inf") for i in range(1, N + 1) for j in range(1, N + 1)}\nfor i in range(1, N + 1):\n dic_edge_dist[(i, i)] = 0\n\nlist_edge = []\n\ndef warshall_floyd(dic_edge_dist):\n dic_shortest_dist = dic_edge_dist.copy()\n for i in range(1, N + 1):\n for j in range(1, N + 1):\n for k in range(1, N + 1):\n dic_shortest_dist[(j, k)] = min(dic_shortest_dist[(j, k)], dic_shortest_dist[(j, i)] + dic_shortest_dist[(i, k)])\n return dic_shortest_dist\n\n\nfor _ in range(M):\n \n a, b, c = map(int, input().split())\n \n dic_edge_dist[(a, b)] = c\n dic_edge_dist[(b, a)] = c\n \n list_edge.append((min(a, b), max(a, b)))\n\ndic_shortest_dist = warshall_floyd(dic_edge_dist)\n \nedge_count = 0\nfor i, j in list_edge:\n for k in range(1, N + 1):\n if dic_shortest_dist[(k, i)] + dic_edge_dist[(i, j)] == dic_shortest_dist[(k, j)]:\n edge_count += 1\n print(i, j, k)\n break\n if dic_shortest_dist[(k, j)] + dic_edge_dist[(j, i)] == dic_shortest_dist[(k, i)]:\n edge_count += 1\n print(i, j, k)\n break\n\nprint(dic_edge_dist)\nprint(dic_shortest_dist)\nprint(len(list_edge) - edge_count)', '\nN, M = map(int, input().split())\n\n\ndic_edge_dist = {(i, j) : float("inf") for i in range(1, N + 1) for j in range(1, N + 1)}\nfor i in range(1, N + 1):\n dic_edge_dist[(i, i)] = 0\n\nlist_edge = []\n\ndef warshall_floyd(dic_edge_dist):\n dic_shortest_dist = dic_edge_dist.copy()\n for i in range(1, N + 1):\n for j in range(1, N + 1):\n for k in range(1, N + 1):\n dic_shortest_dist[(j, k)] = min(dic_shortest_dist[(j, k)], dic_shortest_dist[(j, i)] + dic_shortest_dist[(i, k)])\n return dic_shortest_dist\n\n\nfor _ in range(M):\n \n a, b, c = map(int, input().split())\n \n dic_edge_dist[(a, b)] = c\n dic_edge_dist[(b, a)] = c\n \n list_edge.append((min(a, b), max(a, b)))\n\ndic_shortest_dist = warshall_floyd(dic_edge_dist)\n \nedge_count = 0\nfor i, j in list_edge:\n for k in range(1, N + 1):\n if dic_shortest_dist[(k, i)] + dic_edge_dist[(i, j)] == dic_shortest_dist[(k, j)]:\n edge_count += 1\n break\n if dic_shortest_dist[(k, j)] + dic_edge_dist[(j, i)] == dic_shortest_dist[(k, i)]:\n edge_count += 1\n break\n\nprint(len(list_edge) - edge_count)']
['Wrong Answer', 'Accepted']
['s839684218', 's928232727']
[6188.0, 5496.0]
[661.0, 638.0]
[1590, 1490]
p03837
u188745744
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['N,M=list(map(int,input().split()))\nimport numpy as np\nfrom scipy.sparse.csgraph import floyd_warshall\nfrom scipy.sparse import csr_matrix\nl=[np.array([0]*N) for i in range(N)]\nfor i in range(M):\n tmp=(list(map(int,input().split())))\n l[tmp[0]-1][tmp[1]-1]=tmp[2]\n l[tmp[1]-1][tmp[0]-1]=tmp[2]\nl2=csr_matrix(l)\nl2=floyd_warshall(l2)\nprint(l,l2)\nans=0\nfor i in range(N):\n for j in range(i):\n if l[i][j] != l2[i][j] and l[i][j] != 0:\n ans+=1\nprint(ans)', 'N,M=list(map(int,input().split()))\nimport numpy as np\nfrom scipy.sparse.csgraph import floyd_warshall\nfrom scipy.sparse import csr_matrix\nl=[np.array([0]*N) for i in range(N)]\nfor i in range(M):\n tmp=(list(map(int,input().split())))\n l[tmp[0]-1][tmp[1]-1]=tmp[2]\n l[tmp[1]-1][tmp[0]-1]=tmp[2]\nl2=csr_matrix(l)\nl2=floyd_warshall(l2)\nans=0\nfor i in range(N):\n for j in range(i):\n if l[i][j] != l2[i][j] and l[i][j] != 0:\n ans+=1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s231649857', 's399201625']
[25328.0, 26236.0]
[375.0, 382.0]
[470, 458]
p03837
u200030766
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["\nV, E=map(int,input().strip().split(' '))\ninf=10**9\ncost=[[inf]*V for i in range(V)]\nedge=[]\nfor i in range(E):\n fr, to, co=map(int,input().strip().split(' '))\n cost[fr-1][to-1]=co\n cost[to-1][fr-1]=co\n edge.append([fr-1,to-1])\n \nd=[]\nfor i in range(V):\n d.append(dijkstra(i))\n\ncand=E\nfor i in range(E):\n fl=False\n for j in range(V):\n for k in range(V):\n if d[j][edge[i][0]]==cost[edge[i][0]][edge[i][1]]+d[k][edge[i][1]]:\n cand-=1\n fl=True\n break\n if fl:\n break\n\nprint(cand)\n\ndef dijkstra(s):\n d=[inf]*V\n used=[False]*V\n d[s]=0\n while True:\n v=-1\n for u in range(V):\n if used[u]==False and(v==-1 or d[u]<d[v]):\n v=u\n if v==-1:\n break\n used[v]=True\n for u in range(V):\n d[u]=min(d[u],d[v]+cost[v][u])\n return d\n\n\n", "def dijkstra(s):\n d=[inf]*V\n used=[False]*V\n d[s]=0\n while True:\n v=-1\n for u in range(V):\n if used[u]==False and(v==-1 or d[u]<d[v]):\n v=u\n if v==-1:\n break\n used[v]=True\n for u in range(V):\n d[u]=min(d[u],d[v]+cost[v][u])\n return d\n\n\n\nV, E=map(int,input().strip().split(' '))\ninf=10**9\ncost=[[inf]*V for i in range(V)]\nedge=[]\nfor i in range(E):\n fr, to, co=map(int,input().strip().split(' '))\n cost[fr-1][to-1]=co\n cost[to-1][fr-1]=co\n edge.append([fr-1,to-1])\n \nd=[]\nfor i in range(V):\n d.append(dijkstra(i))\n\ncand=E\nfor i in range(E):\n fl=False\n for s in range(V):\n if d[s][edge[i][0]]+cost[edge[i][0]][edge[i][1]]==d[s][edge[i][1]]:\n cand-=1\n fl=True\n break\n\nprint(cand)"]
['Runtime Error', 'Accepted']
['s489056248', 's580118453']
[3188.0, 3504.0]
[21.0, 452.0]
[938, 838]
p03837
u232852711
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n, m = list(map(int, input().split()))\nconnect = {}\ndist = {}\nfor _ in range(m):\n a, b, c = list(map(int, input().split()))\n if not a in connect.keys(): connect[a] = [b]\n else: connect[a].append(b)\n if not b in connect.keys(): connect[b] = [a]\n else: connect[b].append(a)\n \n dist[tuple(sorted([a, b]))] = c\n\nans = 0\nfor s in range(1, n):\n for t in range(s+1, n+1):\n if not (s, t) in dist.keys():\n continue\n \n dists = [1000]*(n+1)\n dists[s] = 0\n stack = [(s, sc) for sc in connect[s]]\n while len(stack) > 0:\n s0, s1 = stack[0]\n stack = stack[1:]\n if dists[s0]+dist[tuple(sorted((s0, s1)))] >= dists[s1]:\n continue\n else:\n dists[s1] = dists[s0]+dist[tuple(sorted((s0, s1)))]\n for s2 in connect[s1]:\n stack.append((s1, s2))\n print(dists)\n if dists[t] < dist[(s, t)]:\n ans += 1\n\nprint(ans)', 'n, m = list(map(int, input().split()))\ndist_given = {}\ndist = [[1000]*(n+1) for _ in range(n+1)]\nfor i in range(1, n+1): dist[i][i] = 0\nfor _ in range(m):\n a, b, c = list(map(int, input().split()))\n dist[a][b] = c\n dist[b][a] = c\n dist_given[tuple(sorted([a, b]))] = c\n\nfor k in range(1, n+1):\n for i in range(1, n+1):\n for j in range(1, n+1):\n dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])\n# print(dist)\nans = 0\nfor i in range(1, n):\n for j in range(i+1, n+1):\n if (i, j) in dist_given.keys() and dist[i][j] < dist_given[(i, j)]:\n ans += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s954159591', 's369395663']
[3700.0, 3568.0]
[2104.0, 572.0]
[995, 611]
p03837
u252805217
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['from itertools import product as prod\n\nn, m = [int(x) for x in input().split()]\n\ngr = [[] for _ in range(n)]\nfor _ in range(m):\n a, b, c = [int(x) for x in input().split()]\n a -= 1\n b -= 1\n gr[a].append((b, c))\n gr[b].append((a, c))\n\nnumset = set(range(n))\ndef dist(i, j, gr=gr):\n tmp_d = float("inf")\n if i == j:\n return 0\n for (node, d) in gr[i]:\n if node == j:\n tmp_d = d\n # gr_cp = [[(n, d) for (n, d) in g if n != i] for g in gr]\n numset.remove(i)\n routes = [d + dist(n, j, gr=gr) for (n, d) in gr[i] if n in numset]\n\n return min(routes + [tmp_d])\n\nans = 0\nfor i in range(n):\n for (j, d) in gr[i]:\n if dist(i, j) < d:\n ans += 1\n\nprint(ans // 2)\n', 'from itertools import product as prod\n\nn, m = [int(x) for x in input().split()]\n\ngr = [[] for _ in range(n)]\nfor _ in range(m):\n a, b, c = [int(x) for x in input().split()]\n a -= 1\n b -= 1\n gr[a].append((b, c))\n gr[b].append((a, c))\n\ndef dist(i, j, gr=gr):\n tmp_d = float("inf")\n if i == j:\n return 0\n if (j, _) in gr[i]:\n tmp_d = _\n nds = gr[i].copy()\n gr[i] = []\n routes = [d + dist(n, j) for (n, d) in nds]\n \n return min(routes + [tmp_d])\n\nans = 0\nfor i in range(n):\n for (j, d) in gr[i]:\n if dist(i, j) < d:\n ans += 1\n\nprint(ans // 2)', 'from itertools import product as prod\n\nn, m = [int(x) for x in input().split()]\n\ngr = [[] for _ in range(n)]\nfor _ in range(m):\n a, b, c = [int(x) for x in input().split()]\n a -= 1\n b -= 1\n gr[a].append((b, c))\n gr[b].append((a, c))\n\ndef dist(i, j, gr=gr):\n tmp_d = float("inf")\n if i == j:\n return 0\n for (n, d) in gr[i]:\n if n == j:\n tmp_d = d\n gr_cp = [[(n, d) for (n, d) in g if n != i] for g in gr]\n routes = [d + dist(n, j, gr=gr_cp) for (n, d) in gr[i]]\n\n return min(routes + [tmp_d])\n\nans = 0\nfor i, j in prod(range(1, m), range(1,m)):\n for (n, d) in gr[i]:\n if n == j and d > dist(i, j):\n ans += 1\nprint(ans / 2)\n', 'import copy\nfrom itertools import product as prod\n\nn, m = [int(x) for x in input().split()]\n\nwait = [[float("inf") for _ in range(n)] for _ in range(n)]\nfor i in range(n):\n wait[i][i] = 0\nfor _ in range(m):\n a, b, c = map(int, input().split())\n wait[a-1][b-1] = c\n wait[b-1][a-1] = c\n\ndist = copy.deepcopy(wait)\nfor k, i, j in prod(range(n), range(n), range(n)):\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n dist[j][i] = min(dist[j][i], dist[j][k] + dist[k][i])\n\nans = 0\nfor i, j in prod(range(n), range(n)):\n if not wait[i][j] == float("inf") and dist[i][j] < wait[i][j]:\n ans += 1\n\nprint(ans // 2)\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s352817267', 's490352421', 's815158606', 's603094444']
[3444.0, 3444.0, 11508.0, 4212.0]
[29.0, 31.0, 2103.0, 1231.0]
[732, 612, 701, 639]
p03837
u279493135
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom heapq import heappop, heappush, heapify, heappushpop\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\nN, M = MAP()\nabc = [LIST() for _ in range(M)]\n\ndef warshall_floyd(d):\n \n for k in range(N):\n for i in range(N):\n for j in range(N):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\nd = [[INF for i in range(N)] for i in range(N)] \n\nfor x, y, z in abc:\n d[x-1][y-1] = z\n d[y-1][x-1] = z\nfor i in range(N):\n d[i][i] = 0 \n# print(warshall_floyd(d))\ncount = 0\nfor a, b, c in abc:\n\tfor i in range(N):\n\t\tif d[i][a-1] + c == d[a-1][b-1]:\n\t\t\tbreak\n\telse:\n\t\tcount += 1\nprint(count)", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom heapq import heappop, heappush, heapify, heappushpop\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\nN, M = MAP()\nabc = [LIST() for _ in range(M)]\n\ndef warshall_floyd(d):\n \n for k in range(N):\n for i in range(N):\n for j in range(N):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\nd = [[INF for i in range(N)] for i in range(N)] \n\nfor x, y, z in abc:\n d[x-1][y-1] = z\n d[y-1][x-1] = z\nfor i in range(N):\n d[i][i] = 0 \nwarshall_floyd(d)\ncount = 0\nfor a, b, c in abc:\n\tfor i in range(N):\n\t\tif d[i][a-1] + c == d[a-1][b-1]:\n\t\t\tbreak\n\telse:\n\t\tcount += 1\nprint(count)"]
['Wrong Answer', 'Accepted']
['s887235337', 's090045344']
[3944.0, 4192.0]
[53.0, 444.0]
[1314, 1305]
p03837
u316386814
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n, m = list(map(int, input().split()))\n\nimport numpy as np\ndists = np.ones((n + 1, n + 1)) * (10 ** 6)\nedges = []\nfor _ in range(m):\n a, b, c = list(map(int, input().split()))\n dists[a, b] = dists[b, a] = c\n edges.append(a, b, c)\nfor i in range(1, n + 1):\n dists[i, i] = 0\nfor i in range(1, 1 + n):\n dists = np.minimum(dists, dists[i: i + 1] + dists[:, i: i + 1])\ncnt = 0\nfor a, b, c in edges:\n if dists[a, b] < c:\n cnt += 1\n\nprint(cnt)\n', 'n, m = list(map(int, input().split()))\n\nimport numpy as np\ndists = np.ones((n + 1, n + 1)) * (10 ** 6)\nedges = []\nfor _ in range(m):\n a, b, c = list(map(int, input().split()))\n dists[a, b] = dists[b, a] = c\n edges.append((a, b, c))\nfor i in range(1, n + 1):\n dists[i, i] = 0\nfor i in range(1, 1 + n):\n dists = np.minimum(dists, dists[i: i + 1] + dists[:, i: i + 1])\ncnt = 0\nfor a, b, c in edges:\n if dists[a, b] < c:\n cnt += 1\n\nprint(cnt)\n']
['Runtime Error', 'Accepted']
['s213294744', 's382913110']
[12636.0, 22304.0]
[148.0, 312.0]
[462, 464]
p03837
u326552320
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tD_fix\n# CreatedDate: 2020-02-21 01:20:19 +0900\n# LastModified: 2020-02-21 02:04:42 +0900\n#\n\n\nimport os\nimport sys\nimport numpy as np\nimport heapq\n\ndef make_matrix(matrix,a,b,c):\n matrix[a-1][b-1] = c\n matrix[b-1][a-1] = c\n\ndef initial_signal(i,matrix):\n d = [2000]*(matrix.shape[0])\n d[i] = 0\n Q = []\n heapq.heappush(Q,(0,i))\n return d,Q\n\ndef relax(matrix,u,v,d,Q):\n if d[v] > d[u]+matrix[u][v]:\n d[v] = d[u]+matrix[u][v]\n heapq.heappush(Q, (d[v],v))\n\n\ndef dijkstra(i,matrix):\n d,Q = initial_signal(i,matrix)\n while Q:\n cost,u = heapq.heappop(Q)\n if d[u]<cost:\n continue\n for v in range(matrix.shape[0]):\n if matrix[u][v]!=0:\n relax(matrix,u,v,d,Q)\n return d\n \n\ndef main():\n N,M = map(int, input().split())\n matrix = np.zeros((N,N),dtype=np.int32)\n for _ in range(M):\n a,b,c = map(int,input().split())\n make_matrix(matrix,a,b,c)\n shortest = []\n for i in range(matrix.shape[0]):\n short = dijkstra(i,matrix)\n shortest.append(short)\n ans=0\n for i in range(N):\n for j in range(N):\n if matrix[i][j]!=0 and matrix[i][j]>shortest[i][j]:\n ans+=1\n print(shortest)\n print(ans//2)\n\n\nif __name__ == "__main__":\n main()\n', '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tD_fix\n# CreatedDate: 2020-02-21 01:20:19 +0900\n# LastModified: 2020-02-21 02:04:42 +0900\n#\n\n\nimport os\nimport sys\nimport numpy as np\nimport heapq\n\ndef make_matrix(matrix,a,b,c):\n matrix[a-1][b-1] = c\n matrix[b-1][a-1] = c\n\ndef initial_signal(i,matrix):\n d = [9000]*(matrix.shape[0])\n d[i] = 0\n Q = []\n heapq.heappush(Q,(0,i))\n return d,Q\n\ndef relax(matrix,u,v,d,Q):\n if d[v] > d[u]+matrix[u][v]:\n d[v] = d[u]+matrix[u][v]\n heapq.heappush(Q, (d[v],v))\n\n\ndef dijkstra(i,matrix):\n d,Q = initial_signal(i,matrix)\n while Q:\n cost,u = heapq.heappop(Q)\n if d[u]<cost:\n continue\n for v in range(matrix.shape[0]):\n if matrix[u][v]!=0:\n relax(matrix,u,v,d,Q)\n return d\n \n\ndef main():\n N,M = map(int, input().split())\n matrix = np.zeros((N,N),dtype=np.int32)\n for _ in range(M):\n a,b,c = map(int,input().split())\n make_matrix(matrix,a,b,c)\n shortest = []\n for i in range(matrix.shape[0]):\n short = dijkstra(i,matrix)\n shortest.append(short)\n ans=0\n for i in range(N):\n for j in range(N):\n if matrix[i][j]!=0 and matrix[i][j]>shortest[i][j]:\n ans+=1\n print(shortest)\n print(ans//2)\n\n\nif __name__ == "__main__":\n main()\n', '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tD_fix_2\n# CreatedDate: 2020-02-21 20:39:32 +0900\n# LastModified: 2020-02-21 23:32:20 +0900\n#\n\n\nimport heapq\ndef initial_signal(i,adj,N):\n d = [float("inf") for _ in range(N)]\n d[i] = 0\n Q = [(0,i)]\n return d,Q\n\ndef relax(n_cost, u, v, adj,d,Q):\n if d[v] > d[u]+n_cost:\n d[v]=d[u]+n_cost\n heapq.heappush(Q,(d[v],v))\n\n\n\ndef dijkstra(i,adj,N):\n d,Q = initial_signal(i,adj,N)\n while Q:\n cost, u = heapq.heappop(Q)\n for n_cost, v in adj[u]:\n relax(n_cost, u, v, adj, d, Q)\n \n return d\n\n\n\ndef main():\n N, M = map(int, input().split())\n adj = [[] for _ in range(N)]\n for _ in range(M):\n a,b,c = map(int, input().split())\n adj[a-1].append((c,b-1))\n adj[b-1].append((c,a-1))\n shortest = []\n for i in range(N):\n shortest.append(dijkstra(i,adj,N))\n ans = 0\n for i in range(N):\n for cost, j in adj[i]:\n if cost>shortest[i][j]:\n ans+=1\n print(shortest)\n print(ans//2)\n\n\nif __name__ == "__main__":\n main()\n', '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tD_fix\n# CreatedDate: 2020-02-21 01:20:19 +0900\n# LastModified: 2020-02-21 02:04:42 +0900\n#\n\n\nimport os\nimport sys\nimport numpy as np\nimport heapq\n\ndef make_matrix(matrix,a,b,c):\n matrix[a-1][b-1] = c\n matrix[b-1][a-1] = c\n\ndef initial_signal(i,matrix):\n d = [float("inf")]*(matrix.shape[0])\n d[i] = 0\n Q = []\n heapq.heappush(Q,(0,i))\n return d,Q\n\ndef relax(matrix,u,v,d,Q):\n if d[v] > d[u]+matrix[u][v]:\n d[v] = d[u]+matrix[u][v]\n heapq.heappush(Q, (d[v],v))\n\n\ndef dijkstra(i,matrix):\n d,Q = initial_signal(i,matrix)\n while Q:\n cost,u = heapq.heappop(Q)\n if d[u]<cost:\n continue\n for v in range(matrix.shape[0]):\n if matrix[u][v]!=0:\n relax(matrix,u,v,d,Q)\n return d\n \n\ndef main():\n N,M = map(int, input().split())\n matrix = np.zeros((N,N),dtype=np.int32)\n for _ in range(M):\n a,b,c = map(int,input().split())\n make_matrix(matrix,a,b,c)\n shortest = []\n for i in range(matrix.shape[0]):\n short = dijkstra(i,matrix)\n shortest.append(short)\n ans=0\n for i in range(N):\n for j in range(N):\n if matrix[i][j]!=0 and matrix[i][j]>shortest[i][j]:\n ans+=1\n print(shortest)\n print(ans//2)\n\n\nif __name__ == "__main__":\n main()\n', '#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tD_fix_2\n# CreatedDate: 2020-02-21 20:39:32 +0900\n# LastModified: 2020-02-21 23:32:20 +0900\n#\n\n\nimport heapq\ndef initial_signal(i,adj,N):\n d = [float("inf") for _ in range(N)]\n d[i] = 0\n Q = [(0,i)]\n return d,Q\n\ndef relax(n_cost, u, v, adj,d,Q):\n if d[v] > d[u]+n_cost:\n d[v]=d[u]+n_cost\n heapq.heappush(Q,(d[v],v))\n\n\n\ndef dijkstra(i,adj,N):\n d,Q = initial_signal(i,adj,N)\n while Q:\n cost, u = heapq.heappop(Q)\n for n_cost, v in adj[u]:\n relax(n_cost, u, v, adj, d, Q)\n \n return d\n\n\n\ndef main():\n N, M = map(int, input().split())\n adj = [[] for _ in range(N)]\n for _ in range(M):\n a,b,c = map(int, input().split())\n adj[a-1].append((c,b-1))\n adj[b-1].append((c,a-1))\n shortest = []\n for i in range(N):\n shortest.append(dijkstra(i,adj,N))\n ans = 0\n for i in range(N):\n for cost, j in adj[i]:\n if cost>shortest[i][j]:\n ans+=1\n print(ans//2)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s050898426', 's552878960', 's610422429', 's908375046', 's567173462']
[14252.0, 14252.0, 3804.0, 14624.0, 3572.0]
[2108.0, 2108.0, 157.0, 2108.0, 155.0]
[1388, 1388, 1115, 1396, 1095]
p03837
u368780724
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import heapq\n\nn, m = [int(i) for i in input().split()]\ninf = 10**10\npath = [[0] * n for _ in range(n)]\nQ = [[inf] * n for _ in range(n)]\nans = 0\npathnum = []\nctr = 0\n\nfor i in range(m):\n a, b, c = map(lambda x: int(x)-1 ,input().split()) \n path[a][b] = path[b][a] = c+1\n pathnum.append((a,b))\n\nfor i in range(n):\n decided = [False for _ in range(n)]\n H = []\n Q[i][i] = 0\n heapq.heappush(H,(0,i))\n while ctr != n:\n while True:\n k = heapq.heappop(H)\n k = k[1]\n if not decided[k]:\n decided[k] = True\n ctr += 1\n break\n for j in range(n):\n if path[k][j] == 0:\n continue\n if decided[j]:\n continue\n Q[i][j] = min(Q[i][k] + path[k][j], Q[i][j])\n heapq.heappush(H,(Q[i][j],j))\n\nfor i in pathnum:\n if Q[i[0]][i[1]] == inf:\n continue\n elif Q[i[0]][i[1]] != path[i[0]][i[1]]:\n ans += 1\nprint(ans)\n ', 'import heapq\n\nn, m = [int(i) for i in input().split()]\ninf = 10**10\npath = [[0] * n for _ in range(n)]\nQ = [[inf] * n for _ in range(n)]\nans = 0\npathnum = []\n\nfor i in range(m):\n a, b, c = map(lambda x: int(x)-1 ,input().split()) \n path[a][b] = path[b][a] = c+1\n pathnum.append((a,b))\n\nfor i in range(n):\n decided = [False for _ in range(n)]\n H = []\n Q[i][i] = 0\n heapq.heappush(H,(0,i))\n for _ in range(n):\n while True:\n k = heapq.heappop(H)\n k = k[1]\n if not decided[k]:\n decided[k] = True\n break\n for j in range(n):\n if path[k][j] == 0:\n continue\n if decided[j]:\n continue\n Q[i][j] = min(Q[i][k] + path[k][j], Q[i][j])\n heapq.heappush(H,(Q[i][j],j))\n\nfor i in pathnum:\n if Q[i[0]][i[1]] == inf:\n continue\n elif Q[i[0]][i[1]] != path[i[0]][i[1]]:\n ans += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s788448694', 's407809011']
[3444.0, 3572.0]
[26.0, 291.0]
[1002, 967]
p03837
u373958718
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n,m=map(int,input().split())\nl=[list(map(int,input().split()))for i in range(m)]\ndist=[[1<<29]*n for i in range(n)]\nfor i in range(n): dist[i][i]=0\nfor a in l:\n dist[a[0]-1][a[1]-1] = min(dist[a[0]-1][a[1]-1],a[2])\n dist[a[1]-1][a[0]-1] = min(dist[a[1]-1][a[0]-1],a[2])\nprint(dist)\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nans=m\nfor a in l:\n flag=False\n for j in range(n): \n if dist[j][a[0]-1]+a[2]==dist[j][a[1]-1]: flag=True\n if flag: ans-=1\nprint(ans)', 'n,m=map(int,input().split())\nl=[list(map(int,input().split()))for i in range(m)]\ndist=[[1<<29]*n for i in range(n)]\nfor i in range(n): dist[i][i]=0\nfor a in l:\n dist[a[0]-1][a[1]-1] = min(dist[a[0]-1][a[1]-1],a[2])\n dist[a[1]-1][a[0]-1] = min(dist[a[1]-1][a[0]-1],a[2])\n# print(dist)\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nans=m\nfor a in l:\n flag=False\n for j in range(n): \n if dist[j][a[0]-1]+a[2]==dist[j][a[1]-1]: flag=True\n if flag: ans-=1\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s470798522', 's789671643']
[3756.0, 3568.0]
[652.0, 621.0]
[559, 562]
p03837
u411858517
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['def warshall_floyd(d, V, M): \n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \n return d\n \nN, M = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(M)]\ndist = [[10 ** 5 for i in range(N)] for i in range(N)]\n\nfor l in L:\n l[0] -= 1\n l[1] -= 1\n \nfor i in range(M):\n dist[L[i][0]][L[i][1]] = L[i][2]\n dist[L[i][1]][L[i][0]] = L[i][2]\n\ndist = warshall_floyd(dist, N, M)\n\nres = M\nfor i in range(M):\n if dist[L[i][0]][L[i][1]] != L[i][2]:\n res -= 1\n \nprint(res)', 'def warshall_floyd(d, V, M): \n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \n return d\n \nN, M = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(M)]\ndist = [[10 ** 5 for i in range(N)] for i in range(N)]\n\nfor l in L:\n l[0] -= 1\n l[1] -= 1\n \nfor i in range(M):\n dist[L[i][0]][L[i][1]] = L[i][2]\n dist[L[i][1]][L[i][0]] = L[i][2]\n\ndist = warshall_floyd(dist, N, M)\n\nres = 0\n\nfor i in range(M):\n if dist[L[i][0]][L[i][1]] != L[i][2]:\n res += 1\n \nprint(res)']
['Wrong Answer', 'Accepted']
['s775442404', 's262132703']
[3572.0, 3572.0]
[458.0, 416.0]
[708, 709]
p03837
u429843511
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['INF=100000000000\n\n\ndef floyd_warshall(dist):\n for i in range(n):\n for j in range(n):\n for k in range(n):\n if (dist[i][j] > dist[i][k]+dist[k][j]):\n dist[i][j] = dist[i][k]+dist[k][j]\n dist[j][i] = dist[i][k]+dist[k][j]\n\nn,m = map(int,input().split())\ndist=[[INF]*n for i in range(n)]\nedges=[]\n\nfor i in range(m):\n ai,bi,ci=map(int,input().split())\n edges.append(tuple([ai-1,bi-1,ci]))\n dist[ai-1][bi-1]=ci\n dist[bi-1][ai-1]=ci\n\nfor i in range(n):\n dist[i][i] = 0\n\nfloyd_warshall(dist)\n\n#print(dist)\ncount = 0\nfor edge in edges:\n ai,bi,ci=edge\n flag = 0\n for s in range(n):\n if dist[s][ai]+ci == dist[s][bi]:\n flag+=1\n\n if flag > 0:\n count+=1\n\nprint(count)\n\n \n \n \n ', 'INF=100000000000\n\n\ndef floyd_warshall(dist):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])\n\nn,m = map(int,input().split())\ndist=[[INF]*n for i in range(n)]\nedges=[]\n\nfor i in range(m):\n ai,bi,ci=map(int,input().split())\n edges.append(tuple([ai-1,bi-1,ci]))\n dist[ai-1][bi-1]=ci\n dist[bi-1][ai-1]=ci\n\nfor i in range(n):\n dist[i][i] = 0\n\nfloyd_warshall(dist)\n\n#print(dist)\nans = m\nfor edge in edges:\n ai,bi,ci=edge\n flag = 0\n for s in range(n):\n if dist[s][ai]+ci == dist[s][bi]:\n flag+=1\n\n if flag > 0:\n ans-=1\n\nprint(ans)\n\n ']
['Wrong Answer', 'Accepted']
['s565564848', 's229652238']
[3444.0, 3440.0]
[273.0, 427.0]
[805, 683]
p03837
u437727817
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n,m = map(int,input().split())\ndist = []\na = []\nb = []\nc = []\n\nfor i in range(m):\n\ta[i], b[i], c[i] = map(int,input().split())\n\tdist[a[i]-1][b[i]-1] = c[i]\n\tdist[b[i]-1][a[i]-1] = c[i]\n\n\n\n\n\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tfor k in range(n):\n\t\t\tdist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nres = 0\nfor i in range(m):\n\tif c[i] > dist[a[i]-1][b[i]-1]:\n\t\tres += 1\n\nprint (res)\n', 'n,m = map(int,input().split())\n\ndist = [[10**10 for i in range(n)]for j in range(n)]\nfor i in range(n):\n\tdist[i][i] == 0\n\na = [0]*m\nb = [0]*m\nc = [0]*m\n\nfor i in range(m):\n\ta[i], b[i], c[i] = map(int,input().split())\n\tdist[a[i]-1][b[i]-1] = c[i]\n\tdist[b[i]-1][a[i]-1] = c[i]\n\n\n\n\n\nfor k in range(n):\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tdist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\n\nres = 0\nfor i in range(m):\n\tif c[i] > dist[a[i]-1][b[i]-1]:\n\t\tres += 1\n\nprint(res)\n']
['Runtime Error', 'Accepted']
['s675486617', 's566572085']
[3064.0, 3392.0]
[18.0, 555.0]
[452, 541]
p03837
u477320129
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['#!/usr/bin/env python3\nimport sys\n\ndef solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):\n import numpy as np \n from scipy.sparse import csr_matrix \n from scipy.sparse.csgraph import floyd_warshall\n omat = csr_matrix((c, (a, b)), shape=(N+1, N+1), dtype=np.int32, directed=False)\n smat = floyd_warshall(omat)\n return ((omat-smat) > 0).sum() // 2\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n a = [int()] * (M) # type: "List[int]"\n b = [int()] * (M) # type: "List[int]"\n c = [int()] * (M) # type: "List[int]"\n for i in range(M):\n a[i] = int(next(tokens))\n b[i] = int(next(tokens))\n c[i] = int(next(tokens))\n print(solve(N, M, a, b, c))\n\ndef test():\n import doctest\n doctest.testmod()\n\nif __name__ == \'__main__\':\n #test()\n main()\n', '#!/usr/bin/env python3\nimport sys\n\ndef solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):\n import numpy as np \n from scipy.sparse import csr_matrix \n from scipy.sparse.csgraph import floyd_warshall\n omat = csr_matrix((c, (a, b)), shape=(N+1, N+1), dtype=np.int32)\n smat = floyd_warshall(omat, directed=False)\n return ((smat-omat) < 0).sum()\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n a = [int()] * (M) # type: "List[int]"\n b = [int()] * (M) # type: "List[int]"\n c = [int()] * (M) # type: "List[int]"\n for i in range(M):\n a[i] = int(next(tokens))\n b[i] = int(next(tokens))\n c[i] = int(next(tokens))\n print(solve(N, M, a, b, c))\n\ndef test():\n import doctest\n doctest.testmod()\n\nif __name__ == \'__main__\':\n #test()\n main()\n']
['Runtime Error', 'Accepted']
['s977828810', 's006373485']
[41456.0, 38188.0]
[390.0, 187.0]
[1092, 1087]
p03837
u489108157
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["n, m = map(lambda x: int(x), input().split())\na = [0] * m\nb = [0] * m\nc = [0] * m\nfor i in range(m):\n a[i], b[i], c[i] = map(lambda x: int(x), input().split())\n\ndef dijkstra(graph, start, end):\n print('start:{}, end:{}'.format(start, end))\n cost = [1000*100 for _ in range(n+1)]\n fixed = [False for _ in range(n+1)]\n cost[start] = 0\n fixed[start] = True\n tmp_sta = start\n while True:\n tmp_min = 1000*100\n for i in graph[tmp_sta]:\n cost[i[0]] = min(cost[i[0]], cost[tmp_sta]+i[1])\n for i in range(1, n+1):\n if tmp_min > cost[i] and fixed[i] == False:\n tmp_min = cost[i]\n tmp_sta = i\n if tmp_sta == end:\n return tmp_min\n else:\n fixed[tmp_sta] = True\n \ngraph = {}\nfor i in range(1, n+1):\n graph[i] = []\nfor i in range(m):\n graph[a[i]].append((b[i], c[i]))\n graph[b[i]].append((a[i], c[i]))\nprint(graph)\n \nans = 0\nfor i in range(m):\n if c[i] > dijkstra(graph, a[i], b[i]):\n ans += 1\nprint(ans)", 'n, m = map(lambda x: int(x), input().split())\na = [0] * m\nb = [0] * m\nc = [0] * m\nfor i in range(m):\n a[i], b[i], c[i] = map(lambda x: int(x), input().split())\n\ndef dijkstra(graph, start):\n cost = [1000*100 for _ in range(n+1)]\n fixed = [False for _ in range(n+1)]\n cost[start] = 0\n fixed[start] = True\n tmp_sta = start\n while True:\n tmp_min = 1000*100\n for i in graph[tmp_sta]:\n cost[i[0]] = min(cost[i[0]], cost[tmp_sta]+i[1])\n for i in range(1, n+1):\n if tmp_min > cost[i] and fixed[i] == False:\n tmp_min = cost[i]\n tmp_sta = i\n if tmp_min == 1000*100:\n return cost\n else:\n fixed[tmp_sta] = True\n \ngraph = {}\nfor i in range(1, n+1):\n graph[i] = []\nfor i in range(m):\n graph[a[i]].append((b[i], c[i]))\n graph[b[i]].append((a[i], c[i]))\n\ncost2d = [[]]\nfor i in range(1, n+1):\n cost2d.append(dijkstra(graph, i))\n\nans = 0\nfor i in range(m):\n if c[i] > cost2d[a[i]][b[i]]:\n ans += 1\nprint(ans)']
['Wrong Answer', 'Accepted']
['s432590639', 's213895071']
[3316.0, 3444.0]
[783.0, 162.0]
[1047, 1046]
p03837
u505420467
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["from scipy.sparse.csgraph import floyd_warshall\nfrom scipy.sparse.csgraph import dijkstra\nn,m=map(int,input().split())\ndis=[[float('inf') for i in range(n)]for j in range(n)]\nfor i in range(n):\n dis[i][i]=0\nfor i in range(m):\n a,b,t=map(int,input().split())\n dis[a-1][b-1]=t\n dis[b-1][a-1]=t\ncost=dijkstra(dis,directed=False,unweighted=False)\ncnt=0\nfor i,j,k in dis:\n if k>costs[i-1][j-1]:\n cnt+=1\nprint(cnt)\n", "n, m = map(int, input().split())\nINF = float('inf')\ngraph = [[INF for i in range(n)] for j in range(n)]\ntmp = []\n\nfor i in range(m):\n a, b, c = map(int, input().split())\n graph[a - 1][b - 1] = c\n graph[b - 1][a - 1] = c\n tmp.append((a - 1, b - 1, c))\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])\n\nans = 0\nfor a, b, c in tmp:\n if c > graph[a][b]:\n ans += 1\n\nprint(ans)\n"]
['Runtime Error', 'Accepted']
['s791274953', 's089600840']
[17176.0, 3444.0]
[279.0, 583.0]
[431, 485]
p03837
u557494880
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
["\ndef warshall_floyd(d):\n \n for k in range(1,n+1):\n for i in range(1,n+1):\n for j in range(1,n+1):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n##############################\nn,w = map(int,input().split()) \nd = [[float('inf') for i in range(n+1)] for i in range(n+1)] \n\nW = []\nfor i in range(w):\n x,y,z = map(int,input().split())\n W.append((x,y,z))\n d[x][y] = z\n d[y][x] = z\nfor i in range(n):\n d[i][i] = 0 \na = 1\nfor i in range(w):\n x,y,z = W[i][0],W[i][1],W[i][2]\n if d[x][y] < z:\n a += 1\nans = w - a\nprint(ans)\n", "\ndef warshall_floyd(d):\n \n for k in range(1,n+1):\n for i in range(1,n+1):\n for j in range(1,n+1):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\n##############################\nn,w = map(int,input().split()) \nd = [[float('inf') for i in range(n+1)] for i in range(n+1)] \n\nW = []\nfor i in range(w):\n x,y,z = map(int,input().split())\n W.append((x,y,z))\n d[x][y] = z\n d[y][x] = z\nfor i in range(n+1):\n d[i][i] = 0 \na = 0\nwarshall_floyd(d)\nfor i in range(w):\n x,y,z = W[i][0],W[i][1],W[i][2]\n if d[x][y] < z:\n a += 1\nprint(a)"]
['Wrong Answer', 'Accepted']
['s837723528', 's992581635']
[3444.0, 3700.0]
[23.0, 475.0]
[786, 791]
p03837
u594956556
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import sys\nfrom copy import deepcopy\ninput = sys.stdin.readline\nn,m=map(int,input().split())\nd=[[100000]*n for _ in range(n)]\na=[0]*m\nb=[0]*m\nc=[0]*m\nfor i in range(m):\n a0,b0,c0=map(int,input().split())\n a[i]=a0-1\n b[i]=b0-1\n c[i]=c0\n d[a0-1][b0-1]=c0\n d[b0-1][a0-1]=c0\nfor i in range(n):\n d[i][i]=0\nd2=deepcopy(d)\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j]=min(d[i][j],d[i][k]+d[k][j])\ncount=0\nfor i in range(n):\n for j in range(i):\n if d[i][j]!=d[i][j]:\n count+=1\nprint(count)\n', 'N, M = map(int, input().split())\nd = [[1000000]*N for _ in range(N)]\nd_dict = {}\n\ninf = 0\nfor i in range(M):\n a, b, c = map(int, input().split())\n d[a-1][b-1] = c\n d[b-1][a-1] = c\n d_dict[(a-1, b-1)] = c\n \nfor k in range(N):\n for i in range(N):\n for j in range(N):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \nans = 0\nfor key in d_dict:\n if d[key[0]][key[1]] < d_dict[key]:\n ans += 1\n \nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s905591441', 's033445348']
[3964.0, 3444.0]
[544.0, 677.0]
[530, 419]
p03837
u631277801
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['\nfrom heapq import heappush, heappop\n\ndef dijkstra(graph:list, node:int, start:int) -> list:\n \n INF = float("inf")\n dist = [INF]*node\n \n \n dist[start] = 0\n heap = [(0,start)]\n \n \n while heap:\n cost, cur_node = heappop(heap)\n \n for nex_cost, nex_node in graph[cur_node]:\n dist_cand = dist[cur_node] + nex_cost\n if dist_cand < dist[nex_node]:\n dist[nex_node] = dist_cand\n heappush(heap, (dist[nex_node], nex_node))\n \n return dist\n\nclass MakeGraph:\n \n \n \n \n def __init__(self, node_num:int, isMat:bool) -> None:\n self.n = node_num\n self.isMat = isMat\n\n \n if self.isMat:\n INF = float("inf")\n self.graph = [[INF for _ in range(self.n)] for _ in range(self.n)]\n \n \n else:\n self.graph = [[] for _ in range(self.n)]\n\n \n \n \n def add_undr_edge_mat(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm][to] = dist\n self.graph[to][frm] = dist\n \n def add_drct_edge_mat(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm][to] = dist\n \n def add_undr_edge_lst(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm].append((dist, to))\n self.graph[to].append((dist, frm))\n \n def add_drct_edge_lst(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm].append((dist, to))\n\n \n \n def get_graph(self) -> list:\n return self.graph\n\n\nN,M = map(int, input().split())\nABC = []\nfor i in range(M):\n ABC.append(tuple(map(int, input().split())))\n \n \ngraphMaker = MakeGraph(N,False)\nadd_edge = graphMaker.add_undr_edge_lst\n\nfor a,b,c in ABC:\n add_edge(a-1, b-1, c)\n\ngraph = graphMaker.get_graph()\n\ndist = []\nfor i in range(N):\n dist_temp = dijkstra(graph, N, i)\n dist.append(dist_temp)\n \nans = 0\nfor i in range(N):\n for cost, node in graph[i]:\n if dist[i][node] != cost:\n ans += 1\n \n \nprint(ans)\n', 'class MakeGraph:\n \n \n \n \n def __init__(self, node_num:int, isMat:bool) -> None:\n self.n = node_num\n self.isMat = isMat\n\n \n if self.isMat:\n INF = float("inf")\n self.graph = [[INF for _ in range(self.n)] for _ in range(self.n)]\n \n \n else:\n self.graph = [[] for _ in range(self.n)]\n\n \n \n \n def add_undr_edge_mat(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm][to] = dist\n self.graph[to][frm] = dist\n \n def add_drct_edge_mat(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm][to] = dist\n \n def add_undr_edge_lst(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm].append((dist, to))\n self.graph[to].append((dist, frm))\n \n def add_drct_edge_lst(self, frm:int, to:int, dist:int) -> None:\n self.graph[frm].append((dist, to))\n\n \n \n def get_graph(self) -> list:\n return self.graph\n\n\nN,M = map(int, input().split())\nABC = []\nfor i in range(M):\n ABC.append(tuple(map(int, input().split())))\n \ngraphMaker = MakeGraph(N,True)\nadd_edge = graphMaker.add_undr_edge_mat\nfor a,b,c in ABC:\n add_edge(a-1, b-1, c)\n \ngraph = graphMaker.get_graph()\nfor i in range(N):\n graph[i][i] = 0\n\n# WF\nmin_root = [[[] for i in range(N)] for i in range(N)]\nfor i in range(N):\n for j in range(N):\n min_root[i][j].append(j)\n \nfor i in range(N):\n for j in range(N):\n for k in range(N):\n if graph[i][j] >= graph[i][k]+graph[k][j]:\n graph[i][j] = graph[i][k]+graph[k][j]\n min_root[i][j].append(k)\n \nfor i in range(N):\n for j in range(N):\n min_root[i][j].append(i)\n \n\nedge_list = []\nfor a,b,c in ABC:\n edge_list.append([a-1,b-1])\n \n\nfor i in range(N):\n for j in range(N):\n for k in range(len(min_root[i][j])-1):\n if i==j:\n continue\n \n if [min_root[i][j][k], min_root[i][j][k+1]] in edge_list:\n edge_list.remove([min_root[i][j][k], min_root[i][j][k+1]])\n \n \n elif [min_root[i][j][k+1], min_root[i][j][k]] in edge_list:\n edge_list.remove([min_root[i][j][k+1], min_root[i][j][k]])\n \n \nprint(len(edge_list))\n \n ', 'import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom heapq import heappush, heappop\n\ndef dijkstra(graph:list, node:int, start:int) -> list:\n \n INF = float("inf")\n dist = [INF]*node\n \n \n dist[start] = 0\n heap = [(0,start)]\n \n \n while heap:\n cost, cur_node = heappop(heap)\n \n for nex_cost, nex_node in graph[cur_node]:\n dist_cand = dist[cur_node] + nex_cost\n if dist_cand < dist[nex_node]:\n dist[nex_node] = dist_cand\n heappush(heap, (dist[nex_node], nex_node))\n \n return dist\n\nn,m = li()\n\nedges = []\ngraph = [[] for _ in range(n)]\nadj_mat = [[0]*n for _ in range(n)]\n\nfor _ in range(m):\n a,b,c = li()\n a -= 1\n b -= 1\n graph[a].append((c,b))\n graph[b].append((c,a))\n edges.append((a,b,c))\n \n\nfor i in range(n):\n adj_mat[i] = dijkstra(graph, n, i)\n \n \n\nans = 0\nfor ai, bi, ci in edges:\n if adj_mat[ai][bi] < ci:\n ans += 1\n \nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s312783516', 's330795742', 's242829454']
[3692.0, 7640.0, 3660.0]
[97.0, 1240.0, 96.0]
[2556, 2730, 1586]
p03837
u638795007
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['def examD():\n N, M = LI()\n D = [[float("inf") for i in range(N)] for i in range(N)]\n \n XY = [[0,0]]*M\n for i in range(M):\n x, y, z = map(int, input().split())\n XY[i] = [x-1,y-1]\n D[x - 1][y - 1] = z\n D[y - 1][x - 1] = z\n for i in range(N):\n D[i][i] = 0 \n d = copy.deepcopy(D)\n# print(warshall_floyd(N, d))\n W = warshall_floyd(N, d)\n cur = int(0)\n for i in range(M):\n if D[XY[i][0]][XY[i][1]]>W[XY[i][0]][XY[i][1]]:\n cur += 1\n print(cur)\n\nimport sys\nimport copy\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float(\'inf\')\n\nexamD()\n', 'def warshall_floyd(n,d):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j],d[i][k] + d[k][j])\n return d\n\ndef examD():\n N, M = LI()\n D = [[float("inf") for i in range(N)] for i in range(N)]\n \n XY = [[0,0]]*M\n for i in range(M):\n x, y, z = map(int, input().split())\n XY[i] = [x-1,y-1]\n D[x - 1][y - 1] = z\n D[y - 1][x - 1] = z\n for i in range(N):\n D[i][i] = 0 \n d = copy.deepcopy(D)\n# print(warshall_floyd(N, d))\n W = warshall_floyd(N, d)\n cur = int(0)\n for i in range(M):\n if D[XY[i][0]][XY[i][1]]>W[XY[i][0]][XY[i][1]]:\n cur += 1\n print(cur)\n\nimport sys\nimport copy\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float(\'inf\')\n\nexamD()\n']
['Runtime Error', 'Accepted']
['s997243731', 's359895396']
[3956.0, 4292.0]
[35.0, 462.0]
[941, 1159]
p03837
u664373116
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['\nclass Graph():\n \n def __init__(self,vertex_num,node_num,naive_input):\n self.vertex_num=vertex_num\n self.node_num=node_num\n \n \n node=[[] for _ in range(vertex_num)]\n for i in range(node_num):\n u,v=naive_input[i][:2]\n w=naive_input[i][2]\n node[u].append([v,i,w])\n node[v].append([u,i,w])\n self.node=node\n \n self.node_num_arr=list(map(lambda x:len(x),node))\n \n def bfs(self,s=0):\n \n def cal_distance(now_edge,next_edge_info,distance_arr,before_vertex_arr,queue,l_ind):\n next_edge=next_edge_info[0]\n weight=next_edge_info[2]\n cal_distance_val=distance_arr[now_edge]+weight\n if before_vertex_arr[next_edge]==-1:\n queue[l_ind]=next_edge\n #print("queue is updated")\n l_ind+=1\n if cal_distance_val<distance_arr[next_edge]:\n \n distance_arr[next_edge]=cal_distance_val\n before_vertex_arr[next_edge]=now_edge\n \n \n #print(distance_arr)\n \n \n return l_ind\n\n \n q=[-1 for _ in range(self.vertex_num)]\n \n \n \n #cal_node_num_arr=self.node_num_arr.copy()\n now_ind=0\n q[now_ind]=s\n last_ind=1\n\n\n distance=[float("inf") for _ in range(self.vertex_num)]\n distance[s]=0\n before_vertex=[-1 for _ in range(self.vertex_num)]\n before_vertex[s]=s\n index_arr=[-1 for _ in range(self.node_num)]\n\n while last_ind<self.vertex_num:\n now_edge=q[now_ind]\n \n for next_edge_info in self.node[now_edge]:\n \n #cal_node_num_arr[now_edge]-=1\n #cal_node_num_arr[next_edge]-=1\n #q[last_ind]=next_edge\n \n \n\n \n\n last_ind=cal_distance(now_edge,next_edge_info,distance,before_vertex,q,last_ind)\n \n now_ind+=1\n \n return distance\n\nn,m=list(map(int,input().split()))\n"""\nmaze=[[i for i in input()] for _ in range(n)]\ngraph=[[] for _ in range(n*m)]\nq_num=0\nfor i in range(n):\n for j in range(m):\n if maze[i][j]=="#":\n continue\n ind=i*m+j\n q_num+=1\n #move[i][j]=ind\n if i!=0:\n if maze[i-1][j]!="#":\n graph[ind].append((i-1)*m+j)\n if i!=n-1:\n if maze[i+1][j]!="#":\n graph[ind].append((i+1)*m+j)\n if j!=0:\n if maze[i][j-1]!="#":\n graph[ind].append(i*m+j-1)\n \n if j!=m-1:\n if maze[i][j+1]!="#":\n graph[ind].append(i*m+j+1)\n\na=[]\nfor num,i in enumerate(graph):\n for j in i:\n a.append([num,j,1])\n#print(a)\ntmp=0\nfor i in maze:\n for j in i:\n if j==".":\n tmp+=1\nn=tmp\nm=len(a)\n"""\na=[list(map(int,input().split())) for _ in range(m)]\na=list(map(lambda x:[x[0]-1,x[1]-1,x[2]],a))\nG=Graph(n,m,a)\nans=0\nfor i in range(n):\n cal=G.bfs(i)', '#made in 2019/7/1\n#modified in 2020/2/14\nclass Node:\n def __init__(self):\n self.next={}\n def get_data(self,new_next,weight=1):\n self.next[new_next]=weight\n\n\n\ndef dijkstra():\n total=0\n node_cost=[float("inf") for i in range(0,N)]\n now=[E-1]\n node_cost[now[0]]=0\n check=[i for i in range(0,N)]\n check.remove(E-1)\n next_node=node[now[0]].next.keys()\n while len(check):\n total+=1\n tmp=[]\n #print("now", now)\n for each in now:\n next_node=node[each].next.keys()\n for i in next_node:\n val=node[each].next[i]+node_cost[each]\n if node_cost[i]>val:\n node_cost[i]=val\n if i in check:\n #check.remove(i)\n #tmp.extend(node[i].next.keys())\n tmp.append(i)\n now=tmp\n #print("next... ",tmp)\n #print("now...",node_cost)\n if len(now)==0:\n break\n \n print(node_cost)\n print("min_cost:",node_cost[S-1])\n \n\n\n\ndef BFS():\n total=0\n #print("start bfs")\n check_node=[i for i in range(0,N)]\n now=S-1\n tmp=[now]\n check_node.remove(now)\n new_tmp=[]\n while len(check_node)>0:\n #print("tmp:{}".format(tmp))\n total+=1\n for each in tmp:\n #print("each:{}".format(each))\n for i in node[each].next.keys():\n k=i\n #print(k)\n if k in check_node:\n #print("append :{}".format(k))\n new_tmp.append(k)\n check_node.remove(k)\n #print("new_tmp:{}".format(new_tmp))\n #print("check_node:{}".format(check_node))\n tmp=new_tmp\n new_tmp=[]\n print("end")\n print("loop time:{}".format(total))\n \n\n\n\n\n\n\n\n \n \n\n\n#??\nN,M=list(map(int,input().split()))\n#S,E=list(map(int,input().split()))\nnode=[Node() for _ in range(N)]\nans=[[100 for _ in range(N)]for _ in range(N)]\nfor i in range(M):\n tmp_p,tmp_n,tmp_w=list(map(int,input().split()))\n node[tmp_p-1].get_data(tmp_n-1,tmp_w)\n node[tmp_n-1].get_data(tmp_p-1,tmp_w)\n#BFS()\na_num=ord("a")\nfor i in range(N):\n \n S=i+1\n E=i+1\n dijkstra()\n print()\n\n', 'import heapq\nclass Graph():\n def __init__(self,vertex_num,node_num,naive_input,start_zero=True,direction=False):\n self.vertex_num=vertex_num\n self.node_num=node_num\n \n \n node=[{} for _ in range(vertex_num)]\n for i in range(node_num):\n u,v,w=naive_input[i]\n if not start_zero:\n u-=1\n v-=1\n node[u][v]={"weight":w,"index":i}\n #node[v][u]={"weight":w,"index":i}\n if not direction:\n node[v][u]={"weight":w,"index":i}\n #node[u][v]["reverse"]={"weight":w,"index":i}\n self.node=node\n \n self.node_num_arr=list(map(lambda x:len(x),node))\n\n def djikstra(self,s=0):\n distance=[float("inf") for _ in range(self.vertex_num)]\n distance[s]=0\n \n \n \n \n visited_vertex={s}\n before_vertex=[float("inf") for _ in range(self.vertex_num)]\n node_index_arr=[float("inf") for _ in range(self.vertex_num)]\n while len(visited_vertex)<self.vertex_num:\n \n will_visit_node=set()\n for now_node_num in visited_vertex:\n for next_node_num in self.node[now_node_num].keys():\n if next_node_num in visited_vertex:\n continue\n will_visit_node.add(next_node_num)\n next_node=self.node[now_node_num][next_node_num]\n cal_d=distance[now_node_num]+next_node["weight"]\n if cal_d<distance[next_node_num]:\n distance[next_node_num]=cal_d\n before_vertex[next_node_num]=now_node_num\n node_index_arr[next_node_num]=next_node["index"]\n \n #heapq.heappush(min_distance_heap,distance[next_node_num])\n \n add_vertex=[float("inf"),float("inf")]\n for i in will_visit_node:\n if distance[i]<add_vertex[1]:\n add_vertex[0]=i\n add_vertex[1]=distance[i]\n visited_vertex.add(add_vertex[0])\n return node_index_arr\n \n\n\n\n\n\nn,m=list(map(int,input().split()))\na=[list(map(int,input().split())) for _ in range(m)]\nG=Graph(n,m,a,start_zero=False) \nans=[True for _ in range(m)]\nfor i in range(n):\n tmp=G.djikstra(i)\n for j in tmp:\n if j!=float("inf"):\n ans[j]=False\n\nprint(sum(ans))\n\n \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s353750703', 's869254138', 's636767328']
[3444.0, 3444.0, 4084.0]
[45.0, 212.0, 1650.0]
[4236, 2300, 2974]
p03837
u677121387
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n,m = map(int,input().split())\nINF = 10**18\nd = [[INF]*n for _ in range(n)]\nused = [[True]*n for _ in range(n)]\nfor i in range(n): d[i][i] = 0\nfor _ in range(m):\n a,b,c = map(int,input().split())\n a -= 1\n b -= 1\n d[a][b] = c\n d[b][a] = c\n used[a][b] = False\n used[b][a] = False\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n if d[i][j] <= d[i][k] + d[k][j]:\n used[i][j] = True\n used[j][i] = True\n else:\n d[i][j] = d[i][k] + d[k][j]\n\ncnt = 0\nfor i in range(n):\n for j in range(n):\n if used[i][j]: continue\n cnt += 1\nprint(cnt//2)', 'n,m = map(int,input().split())\nINF = 10**18\nd = [[INF]*n for _ in range(n)]\nfor i in range(n): d[i][i] = 0\na = [0]*m\nb = [0]*m\nc = [0]*m\nfor i in range(m):\n a,b,c = map(int,input().split())\n a -= 1\n b -= 1\n a[i] = a\n b[i] = b\n c[i] = c\n d[a][b] = c\n d[b][a] = c\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k]+d[k][j])\n\nans = 0\nfor i in range(m):\n if d[a[i]][b[i]] < c[i]: ans += 1\nprint(ans)', 'n,m = map(int,input().split())\nINF = 10**18\nd = [[INF]*n for _ in range(n)]\nfor i in range(n): d[i][i] = 0\nA = [0]*m\nB = [0]*m\nC = [0]*m\nfor i in range(m):\n a,b,c = map(int,input().split())\n a -= 1\n b -= 1\n A[i] = a\n B[i] = b\n C[i] = c\n d[a][b] = c\n d[b][a] = c\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k]+d[k][j])\n\nans = 0\nfor i in range(m):\n if d[A[i]][B[i]] < C[i]: ans += 1\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s595675770', 's863134321', 's375745077']
[9496.0, 9352.0, 9308.0]
[384.0, 28.0, 455.0]
[692, 484, 484]
p03837
u731028462
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['g = Graph()\nN,M = list(map(int, input().split()))\nINF = 10**9+7\nA = [[INF if i!=j else 0 for i in range(N)] for j in range(N)]\nS=[]\nE=[]\nW=[]\n\nfor i in range(M):\n s,e,w=list(map(int,input().split()))\n g.add_edge(s-1, e-1, w)\n g.add_edge(e-1, s-1, w)\n S.append(s-1)\n E.append(e-1)\n W.append(w)\n\nfor i in range(N):\n d = Dijkstra(g, i)\n for j in range(i+1,N):\n dist = d.shortest_distance(j)\n A[i][j] = dist\n A[j][i] = dist\n \nans=M\nfor i in range(M):\n shortest = False\n for j in range(N):\n if A[j][S[i]] + W[i] == A[j][E[i]]:\n shortest = True\n if shortest:\n ans-=1\n\nprint(ans)', "from collections import defaultdict\nfrom heapq import heappop, heappush\n\nclass Graph(object):\n \n\n def __init__(self):\n self.graph = defaultdict(list)\n\n def __len__(self):\n return len(self.graph)\n\n def add_edge(self, src, dst, weight=1):\n self.graph[src].append((dst, weight))\n\n def get_nodes(self):\n return self.graph.keys()\n\n\nclass Dijkstra(object):\n \n\n def __init__(self, graph, start):\n self.g = graph.graph\n\n \n \n self.dist = defaultdict(lambda: float('inf'))\n self.dist[start] = 0\n\n \n self.prev = defaultdict(lambda: None)\n\n \n self.Q = []\n heappush(self.Q, (self.dist[start], start))\n\n while self.Q:\n \n dist_u, u = heappop(self.Q)\n if self.dist[u] < dist_u:\n continue\n for v, weight in self.g[u]:\n alt = dist_u + weight\n if self.dist[v] > alt:\n self.dist[v] = alt\n self.prev[v] = u\n heappush(self.Q, (alt, v))\n\n def shortest_distance(self, goal):\n \n return self.dist[goal]\n\n def shortest_path(self, goal):\n \n path = []\n node = goal\n while node is not None:\n path.append(node)\n node = self.prev[node]\n return path[::-1]\n\ng = Graph()\nN,M = list(map(int, input().split()))\nINF = 10**9+7\nA = [[INF if i!=j else 0 for i in range(N)] for j in range(N)]\nS=[]\nE=[]\nW=[]\n\nfor i in range(M):\n s,e,w=list(map(int,input().split()))\n g.add_edge(s-1, e-1, w)\n g.add_edge(e-1, s-1, w)\n S.append(s-1)\n E.append(e-1)\n W.append(w)\n\nfor i in range(N):\n d = Dijkstra(g, i)\n for j in range(i+1,N):\n dist = d.shortest_distance(j)\n A[i][j] = dist\n A[j][i] = dist\n \nans=M\nfor i in range(M):\n shortest = False\n for j in range(N):\n if A[j][S[i]] + W[i] == A[j][E[i]]:\n shortest = True\n if shortest:\n ans-=1\n\nprint(ans)"]
['Runtime Error', 'Accepted']
['s179824173', 's025842716']
[3064.0, 3824.0]
[18.0, 119.0]
[658, 2594]
p03837
u736729525
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['def dijkstra(m, s, t):\n INF = 1e10\n D = [INF] * N\n D[s] = 0\n Q = [v for v in range(N)]\n\n while Q:\n d = INF\n v = None\n for x in Q:\n if D[x] <= d:\n d = D[x]\n v = x\n Q.remove(v)\n\n for u, w in enumerate(m[v]):\n if D[u] > D[v] + w:\n D[u] = D[v] + w\n return D[t] \n\nN, M = map(int, input().split())\n\n# N < 100\nm = [[1e10]*N for i in range(N)]\nE = [0] * M\nfor i in range(M):\n a, b, w = map(int, input().split())\n E[i] = a-1, b-1, w\n m[a-1][b-1] = w\n\ncount = 0\nfor a, b, w in E:\n d = dijkstra(m, a, b)\n if d < w:\n count += 1\n\nprint(count)\n', 'import heapq\n\ndef dijkstra(m, s, t):\n INF = 1e10\n D = [INF] * N\n D[s] = 0\n Q = [(0 if s == v else INF, v) for v in range(N)]\n heapq.heapify(Q)\n\n while Q:\n c, u = heapq.heappop(Q)\n if D[u] < c:\n continue\n for v, w in m[u]:\n if D[v] > D[u] + w:\n D[v] = D[u] + w\n heapq.heappush(Q, (D[u]+w, v))\n return D[t] \n\nN, M = map(int, input().split())\n\n# N < 100\nm = [[] for i in range(N)]\nE = [0] * M\nfor i in range(M):\n a, b, w = map(int, input().split())\n E[i] = a-1, b-1, w\n m[a-1].append((b-1,w))\n m[b-1].append((a-1,w))\n\ncount = 0\nfor a, b, w in E:\n d = dijkstra(m, a, b)\n #print((a+1, b+1), d, "w=%d"%w)\n if d < w:\n count += 1\n\nprint(count)\n']
['Wrong Answer', 'Accepted']
['s002059420', 's524405937']
[3188.0, 3316.0]
[2104.0, 644.0]
[672, 758]
p03837
u761989513
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import heapq\n\ndef dijkstra(adj, start, goal=None):\n n = len(adj)\n dist = [float("inf") for i in range(n)]\n prev = [float("inf") for i in range(n)]\n\n dist[start] = 0\n q = []\n heapq.heappush(q, (0, start))\n\n while len(q) != 0:\n prov_cost, src = heapq.heappop(q)\n\n if dist[src] < prov_cost:\n continue\n\n for dest in range(n):\n cost = adj[src][dest]\n if cost != float("inf") and dist[dest] > dist[src] + cost:\n dist[dest] = dist[src] + cost\n heapq.heappush(q, (dist[dest], dest))\n prev[dest] = src\n\n if goal is not None:\n return get_path(goal, prev)\n else:\n return dist\n\ndef get_path(goal, prev):\n path = [goal]\n dest = goal\n while prev[dest] != float("inf"):\n path.append(prev[dest])\n dest = prev[dest]\n return list(reversed(path))\n\nn, m = map(int, input().split())\nadj = [[float("inf") for i in range(n)] for i in range(n)]\npath = []\nfor i in range(m):\n a, b, c = map(int, input().split())\n adj[a - 1][b - 1] = c\n adj[b - 1][a - 1] = c\n path.append(set([a - 1, b - 1]))\nprint(adj)\nfor i in range(n):\n for j in range(n):\n if i != j:\n saitan = dijkstra(adj, i, j)\n for k in range(len(saitan) - 1):\n ss = set(saitan[k:k + 2])\n if ss in path:\n path.remove(ss)\nprint(len(path))', 'import heapq\n\ndef dijkstra(graph, node, start):\n dist = [float("inf") for _ in range(node)]\n\n dist[start] = 0\n q = []\n heapq.heappush(q, (0, start))\n\n while q:\n cost, cur_node = heapq.heappop(q)\n\n for nex_cost, nex_node in graph[cur_node]:\n dist_cand = dist[cur_node] + nex_cost\n if dist_cand < dist[nex_node]:\n dist[nex_node] = dist_cand\n heapq.heappush(q, (dist[nex_node], nex_node))\n\n return dist\n\nn, m = map(int, input().split())\nadj = [[] for _ in range(n)]\nfor i in range(m):\n a, b, c = map(int, input().split())\n a -= 1\n b -= 1\n adj[a].append((c, b))\n adj[b].append((c, a))\nshortest = []\nfor i in range(n):\n shortest.append(dijkstra(adj, n, i))\nans = 0\nfor i in range(n):\n for cost, j in adj[i]:\n if cost > shortest[i][j]:\n ans += 1\nprint(ans // 2)\n']
['Wrong Answer', 'Accepted']
['s925380395', 's428283750']
[3828.0, 3572.0]
[2104.0, 102.0]
[1428, 880]
p03837
u780962115
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['# cadidates of no shortest paths\nn, m = map(int, input().split())\n\nd = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]\nedge_data=[]\nconnect={i:[] for i in range(1,n+1)}\nfor i in range(m):\n x, y, z = map(int, input().split())\n \n d[x][y] = z\n d[y][x] = z\n connect[x].append(y)\n connect[y].append(x) \n edge_data.append((x,y,z))\nfor i in range(n + 1):\n d[i][i] = 0 \n\n\ndef warshall_floyd(d):\n \n for k in range(1, n + 1):\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n return d\n\nwarshall_floyd(d)\n\n\ncnt=0\nfor some in edge_data:\n x,y,zsome[0],some[1],some[2]\n if d[x][y]<z:\n cnt+=1\nprint(cnt)\n', '# cadidates of no shortest paths\nn, m = map(int, input().split())\n\nd = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]\nedge_data=[]\nconnect={i:[] for i in range(1,n+1)}\nfor i in range(m):\n x, y, z = map(int, input().split())\n \n d[x][y] = z\n d[y][x] = z\n connect[x].append(y)\n connect[y].append(x) \n edge_data.append((x,y,z))\nfor i in range(n + 1):\n d[i][i] = 0 \n\n\ndef warshall_floyd(d):\n \n for k in range(1, n + 1):\n for i in range(1, n + 1):\n for j in range(1, n + 1):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n return d\n\nwarshall_floyd(d)\n\n\ncnt=0\nfor some in edge_data:\n x,y,z=some[0],some[1],some[2]\n if d[x][y]<z:\n cnt+=1\nprint(cnt)\n']
['Runtime Error', 'Accepted']
['s844193191', 's077551613']
[3700.0, 3700.0]
[434.0, 434.0]
[954, 955]
p03837
u784022244
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n,w = map(int,input().split()) \nfrom collections import defaultdict\nD=defaultdict(list)\ndef warshall_floyd(d):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n if d[i][j]>d[i][k]+d[k][j]:\n d[i][j] = d[i][k] + d[k][j]\n D[(i,j)]=D[(i,k)]+D[(k,j)][1:]\n return d\ndone=[[-1]*n for _ in range(n)]\nd = [[float("inf")]*n for i in range(n)] \n\nfor i in range(w):\n x,y,z = map(int,input().split())\n d[x-1][y-1] = z\n d[y-1][x-1] = z\n D[(x-1,y-1)]=[x-1,y-1]\n D[(y-1,x-1)]=[y-1,x-1]\n done[x-1][y-1]=0\n done[y-1][x-1]=0\nfor i in range(n):\n d[i][i] = 0 \nwarshall_floyd(d)\nfor l in D.values():\n for i in range(1,len(l)):\n a=l[i-1]\n b=l[i]\n done[a][b]=1\n done[b][a]=1\nimport numpy as np\ndone=np.array(done)\nans=(done==0).sum()\n#print(D)\n#print(done)\nprint(ans)', 'n,w = map(int,input().split()) \nfrom collections import defaultdict\nD=defaultdict(list)\ndef warshall_floyd(d):\n \n for k in range(n):\n for i in range(n):\n for j in range(n):\n if d[i][j]>d[i][k]+d[k][j]:\n d[i][j] = d[i][k] + d[k][j]\n D[(i,j)]=D[(i,k)]+D[(k,j)][1:]\n return d\ndone=[[-1]*n for _ in range(n)]\nd = [[float("inf")]*n for i in range(n)] \n\nfor i in range(w):\n x,y,z = map(int,input().split())\n d[x-1][y-1] = z\n d[y-1][x-1] = z\n D[(x-1,y-1)]=[x-1,y-1]\n D[(y-1,x-1)]=[y-1,x-1]\n done[x-1][y-1]=0\n done[y-1][x-1]=0\nfor i in range(n):\n d[i][i] = 0 \nwarshall_floyd(d)\nfor l in D.values():\n for i in range(1,len(l)):\n a=l[i-1]\n b=l[i]\n done[a][b]=1\n done[b][a]=1\nimport numpy as np\ndone=np.array(done)\nans=(done==0).sum()\n#print(D)\n#print(done)\nprint(ans//2)']
['Wrong Answer', 'Accepted']
['s954813822', 's544712666']
[16992.0, 16992.0]
[497.0, 492.0]
[1053, 1056]
p03837
u789339072
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\na = [0]*N\nb = [0]*N\nc = [0]*N\nfor i in range(M):\n a[i], b[i], c[i] = map(int, input().split())\n a[i] -=1\n b[i] -=1\n\nMAX = 10**10\ndist = np.zeros((N,N))\ndist += MAX\n\nfor i in range(N):\n dist[i,i] = 0\n\nfor i in range(M):\n dist[a[i], b[i]] = c[i]\n dist[b[i], a[i]] = c[i]\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n dist[i, j] = min(dist[i,j], dist[i,k] + dist[k,j])\n\nans = 0\nfor i in range(M):\n if dist[a[i], b[i]] < c[i]:\n ans += 1', 'import sys\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\na = [0]*M\nb = [0]*M\nc = [0]*M\nfor i in range(M):\n input_data = input().split()\n a[i], b[i], c[i] = map(int, input_data)\n a[i] -=1\n b[i] -=1\n\nMAX = 10**10\ndist = [[MAX for j in range(N)] for i in range(N)]\n#dist += MAX\n\nfor i in range(N):\n dist[i][i] = 0\n\nfor i in range(M):\n dist[a[i]][b[i]] = c[i]\n dist[b[i]][a[i]] = c[i]\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nans = 0\nfor i in range(M):\n if dist[a[i]][b[i]] < c[i]:\n ans += 1\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s761234637', 's927815471']
[14408.0, 3408.0]
[1377.0, 568.0]
[587, 641]
p03837
u808806124
2,000
262,144
You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). A _connected graph_ is a graph where there is a path between every pair of different vertices. Find the number of the edges that are not contained in any shortest path between any pair of different vertices.
['n, m = map(int, input().split())\n\nd = np.ones((n, n)) * 1001\n\nes = []\nfor i in range(m):\n es.append(list(map(int, input().split())))\n\nfor (i, j, w) in es:\n d[i - 1][j - 1] = w\n d[j - 1][i - 1] = w\n\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n l = d[i][k] + d[k][j]\n if d[i][j] > l:\n d[i][j] = l\n\nc = 0\nfor (i, j, w) in es:\n if d[i - 1][j - 1] < w:\n c += 1\n\nprint(c)\n', 'n, m = map(int, input().split())\n\nd = [[1001] * n for i in range(n)]\n\nes = []\nfor i in range(m):\n es.append(list(map(int, input().split())))\n\nfor (i, j, w) in es:\n d[i - 1][j - 1] = w\n d[j - 1][i - 1] = w\n\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n l = d[i][k] + d[k][j]\n if d[i][j] > l:\n d[i][j] = l\n\nc = 0\nfor (i, j, w) in es:\n if d[i - 1][j - 1] < w:\n c += 1\n\nprint(c)']
['Runtime Error', 'Accepted']
['s240412850', 's793289076']
[3064.0, 3556.0]
[17.0, 347.0]
[448, 455]