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
p03427
u635182517
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['s = input()\n\nn = int(s)\nlst = list(map(int, list(s)))\nlst_uniq = list(set(lst))\nlst_ans = [9] * (len(lst) - 1)\n\nif lst_uniq == [9] or len(n) == 1:\n ans = sum(lst)\nelif lst[0] == 1:\n ans = sum(lst_ans)\nelse:\n lst_ans = [lst[0] - 1] + lst_ans\n ans = sum(lst_ans)\n\nprint(ans)\n', 's = input()\n\nn = int(s)\nlst = list(map(int, list(s)))\nlst_uniq = list(set(lst))\n\n\nif lst_uniq == [9] or len(lst) == 1:\n ans = sum(lst)\nelif lst[0] == 1:\n ans = 9 * (len(lst) - 1)\nelse:\n \n ans = lst[0] - 1 + 9 : (len(lst) - 1)\n\nprint(ans)\n', 'n = input()\n\nlst = list(map(int, list(n)))\nprint(sum(lst[0], lst[0] - 1 + 9 * (len(lst) - 1)))\n', 'n = input()\n\nlst = list(map(int, list(n)))\nprint(max(sum(lst), lst[0] - 1 + 9 * (len(lst) - 1)))\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s452136447', 's824686620', 's873894440', 's713811112']
[3060.0, 2940.0, 2940.0, 2940.0]
[17.0, 17.0, 18.0, 18.0]
[285, 314, 95, 97]
p03427
u640922335
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = int(input())\n\nfor i in range(17):\n if 10**i <=N <10**(i+1):\n m=i+1\n break\n\nfor j in range(1,10):\n if (10**(m-1))*j + 10**(m-1)-1 <=N< (j+1)*(10**(m-1))+10**(m-1)-1:\n a = j\n break\n\nprint(a+9*(m-1))', 'N = int(input())\n\nfor i in range(17):\n if 10**i <=N <10**(i+1):\n m=i+1\n break\n\nfor j in range(0,10):\n if (10**(m-1))*j + 10**(m-1)-1 <=N< (j+1)*(10**(m-1))+10**(m-1)-1:\n a = j\n break\n\nprint(a+9*(m-1))']
['Runtime Error', 'Accepted']
['s524520961', 's968721591']
[9156.0, 9096.0]
[30.0, 28.0]
[234, 234]
p03427
u652656291
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["n = input()\nn = list(n)\n\nif n[-2] != '9' and n[-1] != '9':\n n[-2] = '9'\n n[-1] = str(int(n[-1])+1)\n\nN = [int(i) for i in n]\n\nprint(sum(N))\n\n", 'N = list(map(str, input().split()))\nprint(max(sum([int(i) for i in N]), 9*(len(N)-1)+int(N[0])-1))\n', "n = input()\nn = list(n)\n\nif len(n) == 1:\n print(n)\n exit()\n\nif n[-2] != '9' and n[-1] != '9':\n n[-2] = '9'\n n[-1] = str(int(n[-1])+1)\n\nN = [int(i) for i in n]\n\nprint(sum(N))\n\n", "n = input()\n\nif n[-2] != '9' and n[-1] != '9':\n n[-2] = '9'\n n[-1] = str(int(n[-1])+1)\n\nprint(sum(n))", 'N = list(map(str, input().rstrip()))\nprint(max(sum([int(i) for i in N]), 9*(len(N)-1)+int(N[0])-1))\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s257918365', 's382013651', 's793774147', 's897861177', 's010391508']
[2940.0, 2940.0, 3060.0, 3064.0, 2940.0]
[17.0, 19.0, 17.0, 17.0, 17.0]
[231, 99, 268, 103, 100]
p03427
u659640418
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['x = int(input())\nb = 0\nfor i in range(16):\n a = x % 10\n b = b + a\n x = x // 10\n \nprint(b)', 'def num_sum(n):\n\tb = 0\n\tfor i in range(16):\n\t\ta = n % 10\n\t\tb = b + a\n\t\tn = n // 10\n\treturn b\n\nx = int(input())\nf = 0\nfor i in range(17):\n\tc = 10**(16-i)*(x//(10**(16-i))) -1\n\tif c <= 0:\n\t\tc = 0\n\td = max(num_sum(x), num_sum(c), f)\n\tf = d\nprint(f)']
['Wrong Answer', 'Accepted']
['s726965804', 's629125549']
[2940.0, 3060.0]
[17.0, 18.0]
[93, 245]
p03427
u665038048
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n = list(map(int, input().split()))\nprint(max((len(n)-1)*9 + n[0]-1, sum(n)))', 'n = input()\nprint((len(n)-1)*9 + int(n[0]))', 'n = input()\nprint(max((len(n)-1)*9 + int(n[0])-1, sum(n)))', 'n = list(map(int, input().split()))\nprint(max(sum(n), n[0]-1+9*(len(n)-1)))', 'ns = list(map(int, list(input())))\nprint(max(sum(ns), ns[0]-1 + 9*(len(ns)-1)))']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s473035345', 's509659861', 's668679101', 's965085579', 's900103181']
[2940.0, 2940.0, 2940.0, 2940.0, 2940.0]
[17.0, 18.0, 18.0, 17.0, 17.0]
[77, 43, 58, 75, 79]
p03427
u672898046
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['def resolve():\n n = input()\n l = len(n)\n if n[:1] == "9" * l-1: \n print(int(n[0]) + 9*(l-1))\n else:\n print((int(n[0])-1) + (9*(l-1)))\nresolve()', 'def resolve():\n n = input()\n l = len(n)\n if n[1:] == "9" * (l-1): \n print(int(n[0]) + 9*(l-1))\n else:\n print((int(n[0])-1) + (9*(l-1)))\nresolve()']
['Runtime Error', 'Accepted']
['s143576528', 's779638415']
[9052.0, 9164.0]
[32.0, 27.0]
[189, 191]
p03427
u674588203
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N=int(input())\nn=str(N)\nLength=len(n)\n\nans=int(n[0])+9*(Length-1)\n\nprint(ans)', "N=int(input())\n# N=100\nn=str(N)\nLength=len(n)\n\nl=list(n)\n\nif l[1:]==['9']*(Length-1):\n ans=int(n[0])+9*(Length-1)\nelse:\n ans=int(n[0])-1+9*(Length-1)\n\nprint(ans)"]
['Wrong Answer', 'Accepted']
['s477951927', 's596628086']
[8980.0, 9000.0]
[28.0, 28.0]
[77, 167]
p03427
u688375653
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['tes =input()\na = [int(data) for data in tes] \nprint(sum(a))\n', 'tes =input()\na = [int(data) for data in tes] \nno_change = sum(a)\nchanges = a[0]-1 + (len(a)-1)*9\nif changes > no_change:\n\tprint(changes)\nelse:\n\tprint(no_change)']
['Wrong Answer', 'Accepted']
['s525141570', 's953930770']
[3316.0, 2940.0]
[20.0, 17.0]
[60, 160]
p03427
u694665829
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n=input()\nans=0\nfor i in n:\n ans+=int(i)\nprint(ans)', 'n=int(input())\nk=len(str(n))\nc=n//10**(k-1)\nprint(c+9*(k-1) if n==(c+1)*10**(k-1)-1 else c+9*(k-1)-1)']
['Wrong Answer', 'Accepted']
['s413075564', 's541537777']
[9100.0, 9172.0]
[29.0, 31.0]
[54, 101]
p03427
u723583932
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['#AtCoder Grand Contest 021 a\ndef wa(x):\n x=str(x)\n s=0\n for i in x:\n s+=int(i)\n return s\n\nn=int(input())\nketa=len(str(n))\nstart=10**(keta-2)\nstart=max(0,start)\nans=0\nprint(start)\nfor i in range(start,n+1):\n ans=max(ans,wa(i))\nprint(ans)', '#AtCoder Grand Contest 021 a\nn=input()\nketa=len(n)\nc=n[0]\nans=int(c)+9*(keta-1)\nif n[1:]!=("9"*(keta-1)):\n ans-=1\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s786182983', 's900647740']
[9128.0, 9128.0]
[2205.0, 26.0]
[258, 128]
p03427
u724892495
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = input()\nn = N\n\nif len(N) == 1:\n print(N)\n exit()\n\nif N[1:].count(\'9\') == len(N)-1:\n print(sum([int(i) for i in N]))\n exit()\n\nif N[0]!=\'9\' or any(map(lambda x:x!=\'9\',N)):\n n = chr(ord(N[0])-1) + N[1:]\n# elif any(map(lambda x:x!=\'9\',N)):\n# n = chr(min([ord(x) for x in N])-1) + N[1:]\n\nans = int(n[0]+"9"*(len(n)-1))\n\nprint(int(N),ans)\nif int(N) >= ans:\n print(sum([int(i) for i in str(ans)]))\nelse:\n print(sum([int(i) for i in str(ans)]) -1)\n', 'N = input()\nn = N\n\nif len(N) == 1:\n print(N)\n exit()\n\nif N[1:].count(\'9\') == len(N)-1:\n print(N)\n exit()\n\nif N[0]!=\'9\' or any(map(lambda x:x!=\'9\',N)):\n n = chr(ord(N[0])-1) + N[1:]\n# elif any(map(lambda x:x!=\'9\',N)):\n# n = chr(min([ord(x) for x in N])-1) + N[1:]\n\nans = int(n[0]+"9"*(len(n)-1))\n\nprint(int(N),ans)\nif int(N) >= ans:\n print(sum([int(i) for i in str(ans)]))\nelse:\n print(sum([int(i) for i in str(ans)]) -1)\n', 'N = input()\nn = N\n\nif len(N) == 1:\n print(N)\n exit()\n\nif N[1:].count(\'9\') == len(N)-1:\n print(sum([int(i) for i in N]))\n exit()\n\nif N[0]!=\'9\' or any(map(lambda x:x!=\'9\',N)):\n n = chr(ord(N[0])-1) + N[1:]\n# elif any(map(lambda x:x!=\'9\',N)):\n# n = chr(min([ord(x) for x in N])-1) + N[1:]\n\nans = int(n[0]+"9"*(len(n)-1))\n\n# print(int(N),ans)\nif int(N) >= ans:\n print(sum([int(i) for i in str(ans)]))\nelse:\n print(sum([int(i) for i in str(ans)]) -1)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s127608122', 's250858163', 's621370212']
[3064.0, 3064.0, 3064.0]
[18.0, 19.0, 17.0]
[469, 446, 471]
p03427
u727787724
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n=int(input())\nk=list(str(n))\nans=0\nprint(max(sum(k),9*len(k)-9+k[0]-1))\n', 'n=int(input())\nk=list(str(n))\nans=0\nfor i in range(len(k)):\n k[i]=int(k[i])\nprint(max(sum(k),9*len(k)-9+k[0]-1))\n']
['Runtime Error', 'Accepted']
['s114039706', 's711126543']
[2940.0, 2940.0]
[17.0, 17.0]
[73, 116]
p03427
u729294108
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n = list(map(int, list(input().strip())))\nprint(n)\n\ntotal = sum(n)\n\nfor i in range(len(n)):\n subtotal = 0\n for j in range(i - 1):\n subtotal += n[j]\n subtotal += n[i] - 1\n for k in range(i + 1, len(n)):\n subtotal += 9\n\n total = max(total, subtotal)\n\nprint(total)\n', 'n = list(map(int, list(input().strip())))\n\ntotal = sum(n)\n\nfor i in range(len(n)):\n subtotal = 0\n for j in range(i - 1):\n subtotal += n[j]\n subtotal += n[i] - 1\n for k in range(i + 1, len(n)):\n subtotal += 9\n\n total = max(total, subtotal)\n\nprint(total)\n']
['Wrong Answer', 'Accepted']
['s097499252', 's951314903']
[3060.0, 3060.0]
[18.0, 17.0]
[291, 282]
p03427
u732844340
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["import sys\n\nif __name__ == '__main__':\n # n = 100\n # n = 9995\n # n = 3141592653589793\n n = input()\n\n ary = list(map(int, list(str(n))))\n\n \n if len(ary) == 1:\n print(sum(ary))\n sys.exit()\n\n \n if len(ary) == 2:\n if sum(ary) <= 9:\n print(9)\n sys.exit()\n else:\n print(sum(ary))\n sys.exit()\n\n \n ary[1:-1] = [9 for i in range(0, len(ary[1:-1]))]\n\n \n if ary[1:-1].count(9) != len(ary[1:-1]):\n ary[0] = ary[0] - 1\n\n \n if sum(ary[-2:]) < 18:\n ary[-2] = 8\n ary[-1] = 9\n\n print(ary)\n print(sum(ary))\n", "if __name__ == '__main__':\n # n = 100\n # n = 9995\n # n = 3141592653589793\n n = input()\n\n ary = list(map(int, list(str(n))))\n\n \n m = -1\n middle = [9 for i in range(0, len(ary[1:-2]))] \n for i in range(0, 10):\n for j in range(0, 10):\n for k in range(0, 10):\n if m < sum([i] + middle + [j, k]) and int(''.join(map(str, [i] + middle + [j, k]))) <= n:\n m = sum([i] + middle + [j, k])\n print(m)", "if __name__ == '__main__':\n # n = 100\n # n = 9995\n # n = 3141592653589793\n n = input()\n\n ary = list(map(int, list(str(n))))\n\n \n m = -1\n middle = [9 for i in range(0, len(ary[1:-2]))] \n for i in range(0, 10):\n for j in range(0, 10):\n for k in range(0, 10):\n if m < sum([i] + middle + [j, k]) and int(''.join(map(str, [i] + middle + [j, k]))) <= int(n):\n m = sum([i] + middle + [j, k])\n print(m)\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s534568426', 's898143525', 's592441662']
[3064.0, 3188.0, 3064.0]
[18.0, 18.0, 20.0]
[833, 509, 515]
p03427
u735763891
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['_num = int(input())\n_sumlist = []\nfor i in range(num//10, _num + 1):\n _sum = 0\n while i:\n _sum += i % 10\n i //= 10\n _sumlist.append(_sum)\nprint(max(_sumlist))', '_num = int(input())\n_sum = 0\nwhile _num:\n _sum += _num % 10\n _num //= 10\nprint(_sum)', 'def Digit_Sum():\n _num = int(input())\n _sumlist = []\n _digit = 0\n _sumlist.append(digit_sum(_num))\n _sumlist.append(digit_sum((_num // 10) * 10 - 1))\n while _num:\n _digit += 1\n _num //= 10\n _sumlist.append(9 * (_digit - 1))\n print(max(_sumlist))\n\n\ndef digit_sum(_num):\n _sum = 0\n while _num:\n _sum += _num % 10\n _num //= 10\n return _sum', 'def digit_num(_num):\n _digit = 0\n while _num:\n _digit += 1\n _num //= 10\n return _digit\n\ndef ACGC021_A():\n _num = int(input())\n _digit = digit_num(_num)\n _topdig = _num // 10 ** (_digit - 1)\n if (_num - _topdig * 10 ** (_digit - 1)) == 10 ** (_digit - 1) - 1:\n print(_topdig + 9 * (_digit - 1))\n else:\n print(_topdig - 1 + 9 * (_digit - 1))\n\nACGC021_A()']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s275677407', 's886853545', 's905566955', 's484744591']
[3060.0, 2940.0, 3064.0, 3060.0]
[17.0, 17.0, 17.0, 17.0]
[181, 90, 397, 404]
p03427
u749614185
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["Num = str(input())\nL = len(Num)\nif Num[1:] == '9'*(l-1):\n val = int(Num[0]) + 9*(l-1)\nelse:\n val = int(Num[0])-1 + 9*(l-1)\nprint(val)", "Num = str(input())\nL = len(Num)\nif Num[1:] == '9'*(L-1):\n val = int(Num[0]) + 9*(L-1)\nelse:\n val = int(Num[0])-1 + 9*(L-1)\nprint(val)\n"]
['Runtime Error', 'Accepted']
['s572625336', 's990253847']
[8820.0, 8992.0]
[26.0, 32.0]
[135, 136]
p03427
u782654209
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["N=int(input())\nR=len(str(N))\nprint(R)\ndef dsum(X):\n\treturn(sum([ int(n) for n in list(str(X))]))\ncand=[dsum(N)]\nfor i in range(R):\n\ta = (N//(10**i))*(10**i) + int('9'*i) if i>0 else 0\n\tb = (N//(10**i)-1)*(10**i) + int('9'*i) if i>0 else 0\n\tif a<=N:\n\t\tcand.append(dsum(a))\n\telse:\n\t\tcand.append(dsum(b))\nprint(max(cand))\n", "N=int(input())\nR=len(str(N))\ndef dsum(X):\n\treturn(sum([ int(n) for n in list(str(X))]))\ncand=[dsum(N)]\nfor i in range(R):\n\ta = (N//(10**i))*(10**i) + int('9'*i) if i>0 else 0\n\tb = (N//(10**i)-1)*(10**i) + int('9'*i) if i>0 else 0\n\tif a<=N:\n\t\tcand.append(dsum(a))\n\telse:\n\t\tcand.append(dsum(b))\nprint(max(cand))\n"]
['Wrong Answer', 'Accepted']
['s432742108', 's442989081']
[3064.0, 3064.0]
[18.0, 17.0]
[319, 310]
p03427
u785573018
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n = input(); a = 0; b = 0; c = 0\nfor i in range(len(n)):\n if n[i] != "9":\n if a == 0: a += 1; b = i; c = int(n[i])\n else: a += 1\nif a == 0: print(9*len(n))\nelif a == 1 and b == 0: print(c+9*(len(n)-1))\nelse: print(9*len(n)-1)', 'n = input(); a = 0; b = 0; c = int(n[0])\nfor i in range(len(n)):\n if n[i] != "9":\n if a == 0: a += 1; b = i\n else: a += 1\nif a == 0: print(9*len(n))\nelif a == 1 and b == 0: print(c+9*(len(n)-1))\nelse: print(c-1+9*(len(n)-1))']
['Wrong Answer', 'Accepted']
['s785671934', 's734889309']
[9196.0, 9196.0]
[26.0, 29.0]
[242, 241]
p03427
u785578220
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['a = input()\nb = int(a)\nc = list(a)\nt = int(a[0])\n#print(t,a.count("9"))\nif t != 9 and a.count("9") == len(a)-1:\n r = t+(len(a)-1)*9\nelif a.count("9") != len(a):\n t -= 1\n r = t+(len(a)-1)*9\nif b<9:\n r = b\nelse: b == 9\n r = 9\n \nprint(r)', 'a = input()\nb = int(a)\nc = list(a)\nt = int(a[0])\nprint(t,a.count("9"))\nif t != 9 and a.count("9") == len(a)-1:\n r = t+(len(a)-1)*9\nelif a.count("9") != len(a):\n t -= 1\n r = t+(len(a)-1)*9\nif b<9:\n r = b\n \nprint(r)', 'a = input()\nb = int(a)\nc = list(a)\nt = int(a[0])\nr = t+(len(a)-1)*9\n#print(t,a.count("9"))\nif t != 9 and a.count("9") == len(a)-1:\n r = t+(len(a)-1)*9\nelif a.count("9") != len(a):\n t -= 1\n r = t+(len(a)-1)*9\nif b<9:\n r = b\nelif b == 9:\n r = 9\n \nprint(r)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s577725209', 's896913723', 's474609048']
[2940.0, 3060.0, 3064.0]
[17.0, 18.0, 18.0]
[253, 229, 272]
p03427
u787562674
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["N = str(input())\n\nif int(N[1:]) % (9 * int('1' * len(N))) == 0:\n print(int(N[0] + 9 * (len(N)-1)))\nelse:\n print(int(N[0]) - 1 + 9 + 9 * len(N[2:]))\n\n", "N = str(input())\n\nfor item in N[1:]:\n if item != '9':\n print(int(N[0]) - 1 + 9 * (len(N) - 1))\n break\nelse:\n print(int(N[0]) + 9 * len(N[1:]))"]
['Runtime Error', 'Accepted']
['s954732517', 's782072617']
[2940.0, 3060.0]
[19.0, 18.0]
[155, 162]
p03427
u798818115
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N=input()\n\nif len(N)==1:\n print(N)\n exit()\n\ndef calc(str):\n l=list(map(int,str))\n all=sum(l)\n \n return all\n\ncand1=str(int(N)-int(N[-1])-1)\ncand2=str(int(N[0])*10**(len(N)-1)-1)\n\nprint(cand1,cand2,N)\nprint(max(calc(cand1),calc(cand2),calc(N)))', 'N=input()\n\nif len(N)==1:\n print(N)\n exit()\n\ndef calc(str):\n l=list(map(int,str))\n all=sum(l)\n \n return all\n\ncand1=str(int(N)-int(N[-1])-1)\ncand2=str(int(N[0])*10**(len(N)-1)-1)\n\nprint(max(calc(cand1),calc(cand2),calc(N)))']
['Wrong Answer', 'Accepted']
['s407029572', 's344334677']
[3064.0, 3060.0]
[18.0, 17.0]
[260, 239]
p03427
u807772568
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = input()\nt = N[0]\nif N == t + "9"(len(N)-1):\n print(int(t)+9*(len(N)-1))\nelse:\n print(int(t)-1+9*(len(N)-1))', 'N = input()\nt = N[0]\nif N == t + "9"*(len(N)-1):\n print(int(t)+9*(len(N)-1))\nelse:\n print(int(t)-1+9*(len(N)-1))']
['Runtime Error', 'Accepted']
['s888793408', 's536314473']
[3188.0, 2940.0]
[19.0, 17.0]
[113, 114]
p03427
u835482198
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["n = input()\nk = len(n)\nc = int(n[0])\nif n == c + '9' * (k - 1):\n print(int(n[0]) + 9 * (k - 1))\nelse:\n print(int(n[0]) + 9 * (k - 1) - 1)\n", "n = input()\nk = len(n)\nc = n[0]\nif n == c + '9' * (k - 1):\n print(int(n[0]) + 9 * (k - 1))\nelse:\n print(int(n[0]) + 9 * (k - 1) - 1)\n"]
['Runtime Error', 'Accepted']
['s471500015', 's687690917']
[2940.0, 2940.0]
[17.0, 17.0]
[144, 139]
p03427
u842230338
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = input()\nl = len(str(N))-1\nprint(l*9 + (N//(10**l)-1))', 'N = int(input())\nl = len(str(N))-1\nprint(l*9 + ((N+1)//(10**l)-1))']
['Runtime Error', 'Accepted']
['s528667914', 's154588192']
[2940.0, 2940.0]
[18.0, 17.0]
[57, 66]
p03427
u844005364
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['s = input()\n\nif s < 10:\n print(s)\nelse:\n print(int(s[0]) - 1 + 9 * (len(s) - 1))\n', 's = input()\n\nif int(s) < 10:\n print(int(s))\nelif all([x == "9" for x in s[1:]]):\n print(int(s[0]) + 9 * (len(s) - 1))\nelse:\n print(int(s[0]) - 1 + 9 * (len(s) - 1))\n']
['Runtime Error', 'Accepted']
['s576472986', 's897556832']
[2940.0, 3060.0]
[17.0, 25.0]
[87, 174]
p03427
u846634344
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["import sys\nsys.setrecursionlimit(10**6)\nif sys.platform in (['ios','darwin','win32']):\n\tsys.stdin=open('Untitled.txt')\ninput = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return [int(s) for s in input().split()]\n\ndef main():\n\tN = INT()\n\tS = [int(s) for s in str(N)]\n\t# print(S)\n\n\tA = []\n\tsmaller = False\n\tfor i in range(len(S)-1):\n\t\tif smaller:\n\t\t\tA.append(9)\n\t\telse:\n\t\t\tif S[i] == 9 and S[i+1] == 9:\n\t\t\t\tA.append(9)\n\t\t\telif S[i+1] == 9:\n\t\t\t\tA.append(S[i])\n\t\t\telse:\n\t\t\t\tsmaller = True\n\t\t\t\tA.append(S[i]-1)\n\n\tif smaller: A.append(9)\n\telse: A.append(S[-1])\n\n\tprint(A)\n\tprint(sum(A))\n\nif __name__ == '__main__':\n\tmain()", "import sys\nsys.setrecursionlimit(10**6)\nif sys.platform in (['ios','darwin','win32']):\n\tsys.stdin=open('Untitled.txt')\ninput = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return [int(s) for s in input().split()]\n\ndef main():\n\tN = INT()\n\tS = [int(s) for s in str(N)]\n\t# print(S)\n\n\tA = []\n\tsmaller = False\n\tfor i in range(len(S)-1):\n\t\tif smaller:\n\t\t\tA.append(9)\n\t\telse:\n\t\t\tif S[i] == 9 and S[i+1] == 9:\n\t\t\t\tA.append(9)\n\t\t\telif S[i+1] == 9:\n\t\t\t\tA.append(S[i])\n\t\t\telse:\n\t\t\t\tsmaller = True\n\t\t\t\tA.append(S[i]-1)\n\n\tif smaller: A.append(9)\n\telse: A.append(S[-1])\n\n\t# print(A)\n\tprint(sum(A))\n\nif __name__ == '__main__':\n\tmain()"]
['Wrong Answer', 'Accepted']
['s367131997', 's841557530']
[3064.0, 3064.0]
[17.0, 18.0]
[633, 635]
p03427
u858670323
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n = str(input().rstrip()+1)\nans = len(n)*9\nans += int(n[0])-1\nprint(ans)', 'n = str(int(input().rstrip())+1)\nans = (len(n)-1)*9\nans += (int(n[0])-1)\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s926094112', 's372153715']
[2940.0, 2940.0]
[17.0, 17.0]
[72, 84]
p03427
u893063840
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['def main():\n n = input()\n\n l = len(n)\n\n nines = "9" * (l - 1)\n num = int(nines)\n\n for i in range(1, 10):\n tmp = str(i) + nines\n if int(tmp) <= int(n):\n num = tmp\n\n ans = sum(map(int, num))\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n', 'def main():\n n = input()\n\n l = len(n)\n\n nines = "0" + "9" * (l - 1)\n nines = int(nines)\n\n num = nines\n for i in range(1, 10):\n tmp = i * 10 ** (l - 1) + nines\n if tmp <= int(n):\n num = tmp\n\n ans = sum(map(int, str(num)))\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s358364558', 's910442050']
[3060.0, 3060.0]
[17.0, 17.0]
[287, 322]
p03427
u896741788
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['s=input()\nprint(max(int(s),int(s[0])-1+9*len(s)-9))', 's=input()\nprint(max(sum(map(int,list(s))),int(s[0])-1+9*len(s)-9))']
['Wrong Answer', 'Accepted']
['s890457370', 's956480529']
[2940.0, 2940.0]
[17.0, 17.0]
[51, 66]
p03427
u924406834
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n = int(input())\nstrs = [int(x) for x in str(n)]\nkijyun = [9]*(len(strs)-1)\nif strs[1:] == kijyun:\n print((len(strs)-1)*9+strs[1])\nelse:\n print((len(strs)-1)*9+strs[1]-1)', 'n = int(input())\nstrs = [int(x) for x in str(n)]\nkijyun = [9]*(len(strs)-1)\nif strs[1:] == kijyun:\n print((n-1)*9+strs[1])\nelse:\n print((n-1)*9+strs[1]-1)', 'n = int(input())\nstrs = [int(x) for x in str(n)]\nkijyun = [9]*(len(strs)-1)\nif strs[1:] == kijyun:\n print((len(strs)-1)*9+strs[0])\nelse:\n print((len(strs)-1)*9+strs[0]-1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s386113691', 's434416259', 's962638390']
[3060.0, 3188.0, 3060.0]
[17.0, 17.0, 17.0]
[176, 160, 176]
p03427
u934119021
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["n = int(input())\nk = len(str(n))\na = 9 * (k - 1)\nb = 0\nfor i in range(k):\n b += int(str(n)[i])\nc = 0\nif k > 2:\n m = str(int(n))[:k - 2] + str(int(int(str(n)[-2]) - 1)) + '9'\n for i in range(k):\n c += int(m[i])\nans = max(a, b, c)\nprint(ans)", "n = input()\nk = len(n)\na = 9 * (k - 1) + int(n[0]) - 1\nb = 0\nfor i in range(k):\n b += int(n[i])\nc = 0\nm = ''\nif k > 2 and n[-2] != '0':\n m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9'\nelif k > 2 and n[-2] == '0':\n m = str(int(n) - (int(n[-1]) + 1))\nfor i in range(len(m)):\n c += int(m[i])\nans = max(a, b, c)\nprint(ans)"]
['Runtime Error', 'Accepted']
['s757244169', 's486617712']
[9140.0, 9176.0]
[29.0, 29.0]
[245, 327]
p03427
u937642029
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n=int(input())\nif n < 10 :\n print(n)\nelse:\n n=list(str(n))\n key=0\n for i in range(n):\n if n[1+i]!="9":\n key=1\n if key ==0:\n print((len(n)-1)*9+int(n[0]))\n else:\n print((len(n)-1)*9+int(n[0])-1)\n\n\n', 'n=int(input())\nif n < 10 :\n print(n)\nelse:\n n=list(str(n))\n key=0\n for i in range(len(n)-1):\n if n[1+i]!="9":\n key=1\n if key ==0:\n print((len(n)-1)*9+int(n[0]))\n else:\n print((len(n)-1)*9+int(n[0])-1)\n\n']
['Runtime Error', 'Accepted']
['s101193413', 's652619998']
[3060.0, 3064.0]
[17.0, 17.0]
[246, 252]
p03427
u941753895
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["n=list(input())\nif ''.join(n)=='100':\n exit()\nsb=n[1:]\nsetsb=list(set(sb))\nif len(setsb)==1 and setsb[0]=='9':\n if n[0]=='9':\n print(9*len(n))\n else:\n print(int(n[0])-1+9*len(sb))\nelse:\n print(int(n[0])-1+9*len(sb))", "n=list(input())\nif ''.join(n)=='100':\n exit()\nif len(n)==1:\n print(n[0])\n exit()\nsb=n[1:]\nsetsb=list(set(sb))\nif len(setsb)==1 and setsb[0]=='9':\n if n[0]=='9':\n print(9*len(n))\n else:\n print(int(n[0])+9*len(sb))\nelse:\n print(int(n[0])-1+9*len(sb))", "n=list(input())\nif ''.join(n)=='100':\n exit()\nsb=n[1:]\nsetsb=list(set(sb))\nif len(setsb)==1 and setsb[0]=='9':\n if n[0]=='9':\n print(9*len(n))\n else:\n print(int(n[0])+9*len(sb))\nelse:\n print(int(n[0])-1+9*len(sb))", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n=S()\n\n f=False\n for i in range(1,len(n)):\n if n[i]!='9':\n f=True\n\n if f:\n return int(n[0])-1+9*(len(n)-1)\n else:\n return int(n[0])+9*(len(n)-1)\n\nprint(main())"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s194676440', 's521337701', 's737138254', 's464959987']
[3060.0, 3064.0, 3060.0, 5420.0]
[17.0, 17.0, 17.0, 42.0]
[225, 260, 223, 469]
p03427
u941884460
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = input()\nsum = 0\nfor i in range(len(N)):\n sum += int(N[i])\nprint(sum)', "n = input().rstrip()\nif len(n) == 1:\n print(n)\nelse:\n flg = True\n for i in range(1,len(n)):\n if n[i] != '9':\n flg = False\n if flg:\n print(9*(len(n)-1)+int(n[0]))\n else:\n print(9*(len(n)-1)+int(n[0])-1)"]
['Wrong Answer', 'Accepted']
['s398596976', 's247926059']
[2940.0, 3060.0]
[17.0, 17.0]
[73, 220]
p03427
u942051624
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N=list(str(input()))\nans=0\nfor i in range(len(N)):\n ans+=int(N[i])\nprint(ans)', "N=list(str(input()))\nans=0\nfor i in range(1,N):\n if N[i]!='9':\n ans+=int(N[0])-1\n ans+=(len(N)-1)*9\n print(ans)\n exit()\nfor i in range(N):\n ans+=int(N[i])\nprint(ans)\n ", "N=list(str(input()))\nans=0\nif len(N)==1:\n print(int(N[0]))\n exit()\nfor i in range(1,len(N)):\n if N[i]!='9':\n ans+=int(N[0])-1\n ans+=(len(N)-1)*9\n print(ans)\n exit()\nfor i in range(len(N)):\n ans+=int(N[i])\nprint(ans)\n "]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s109597870', 's167533114', 's182580266']
[9084.0, 9092.0, 9204.0]
[27.0, 24.0, 28.0]
[80, 208, 264]
p03427
u947823593
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['#encoding=utf-8\ndef solve(n):\n k = len(n)\n c = str(n)[k - 1]\n if str(n)[1..k] = \'9\' * k:\n return c + 9 * (k - 1)\n return c + 9 * (k - 1) - 1\n\nif __name__ == "__main__":\n n = int(input())\n print(solve(n))\n', '#encoding=utf-8\ndef solve(n):\n k = len(n)\n c = str(n)[k - 1]\n if str(n)[1..k] = \'9\' * k:\n return c + 9 * (k - 1)\n return c + 9 * (k - 1) - 1\n\nif __name__ == "__main__":\n n = int(input())\n print(solve(n))\n', '#encoding=utf-8\ndef solve(n):\n ans_a = calc_digit_sum(n)\n ans_b = calc_digit_sum(n - n % 10 - 1)\n ans_c = calc_digit_sum(10 ** (len(str(n)) - 1) - 1 + 10 ** (len(str(n)) - 1) * (int(str(n)[0]) - 1) )\n return max(ans_a, ans_b, ans_c)\n\ndef calc_digit_sum(n):\n if n <= 0:\n return 0\n str_n = str(n)\n ans = 0\n for x in range(len(str_n)):\n ans = ans + int(str_n[x])\n return ans\n\nif __name__ == "__main__":\n n = int(input())\n print(solve(n))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s281808677', 's843645312', 's870391112']
[2940.0, 2940.0, 3064.0]
[17.0, 17.0, 18.0]
[230, 230, 482]
p03427
u969190727
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['n=int(input())\nprint(int(str(n)[0])-1+9*(len(n)-1))', 'n=int(input())\nans=int(str(n)[0])+9*(len(str(n))-1)\nif str(n)[1:]=="9"*(len(str(n))-1):\n print(ans)\nelse:\n print(ans-1)']
['Runtime Error', 'Accepted']
['s224109697', 's466532238']
[2940.0, 2940.0]
[17.0, 17.0]
[51, 121]
p03427
u981931040
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
["N = input()\ni_N = int(N)\nif len(N) == 1:\n print(N)\n exit()\nans = (len(N) - 1) * 9\nif N[0] != '9':\n ans += int(N[0]) - 1\nelse:\n for i in range(1, len(N)):\n if N[i] != '9':\n ans += int(N[i - 1]) - 1\n break\n else:\n ans += 9\nif ans > i_N:\n print(ans)\nelse:\n print(i_N)\n", "N = input()\ni_N = 0\nfor i in range(len(N)):\n i_N += int(N[i])\nif len(N) == 1:\n print(N)\n exit()\nans = (len(N) - 1) * 9\nif N[0] != '9':\n ans += int(N[0]) - 1\nelse:\n for i in range(1, len(N)):\n if N[i] != '9':\n ans += int(N[i - 1]) - 1\n break\n else:\n ans += 9\nif ans > i_N:\n print(ans)\nelse:\n print(i_N)\n"]
['Wrong Answer', 'Accepted']
['s195839040', 's497255966']
[3064.0, 3064.0]
[17.0, 17.0]
[322, 362]
p03427
u987164499
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['from sys import stdin\n\ns = stdin.readline().rstrip()\n\nif len(s) == 1:\n print(int(s))\n exit()\n\nif s == "9"*len(s):\n print(9*len(s))\nelse:\n print(max(int(s[0])-1+9*(len(s)-1),int(s[0])+9*(len(s)-1)))', 'from sys import stdin\n\ns = stdin.readline().rstrip()\n\nif len(s) == 1:\n print(int(s))\n exit()\n\nif s == "9"*len(s):\n print(9*len(s))\nelse:\n if s[1:] == "9"*(len(s)-1):\n print(int(s[0])+9*(len(s)-1))\n else:\n print(int(s[0])-1+9*(len(s)-1))']
['Wrong Answer', 'Accepted']
['s187706923', 's259169288']
[3060.0, 3060.0]
[17.0, 17.0]
[209, 265]
p03427
u988832865
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['import scipy', "def poyo():\n ans = -1\n A = []\n for i in range(1, 100):\n t = sum([ord(x) - ord('0') for x in str(i)])\n ans = max(ans, t)\n A.append(ans)\n # print(ans)\n\n import numpy as np\n maxi, cnt = np.unique(A, return_counts=True)\n print(maxi)\n print(np.cumsum(cnt))\n for x, y in zip(maxi, np.cumsum(cnt)):\n print(x, y)\n\n\ndef naive(N):\n ans = -1\n for i in range(N + 1):\n t = sum([ord(x) - ord('0') for x in str(i)])\n ans = max(ans, t)\n return ans\n\n\n# poyo()\nimport math\n\n\ndef solve(N):\n if N < 10:\n return (N)\n else:\n ans = (len(str(N + 1)) - 1) * 9\n ans += ord(str(N + 1)[0]) - ord('0') - 1\n return (ans)\n\n\ndef check():\n for i in range(10000):\n # print(i)\n assert solve(i) == naive(i)\n\n\nN = int(input())\nprint(solve(N))\n"]
['Wrong Answer', 'Accepted']
['s739402027', 's754120180']
[21532.0, 3064.0]
[1596.0, 18.0]
[12, 839]
p03427
u989306199
2,000
262,144
Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
['N = int(input())\nn = len(str(N))\nNS = str(N)\nans0 = 0\nfor i in range(NS):\n ans0 += int(i)\nans1 = int(NS[0])-1 + 9 * (n-1)\nans2 = 9 * (n-1)\n\nprint(max(ans0, ans1, ans2))\n', 'N = int(input())\nn = len(str(N))\nNS = str(N)\nans0 = 0\nfor i in NS:\n ans0 += int(i)\nans1 = int(NS[0])-1 + 9 * (n-1)\nans2 = 9 * (n-1)\n\nprint(max(ans0, ans1, ans2))\n']
['Runtime Error', 'Accepted']
['s848598837', 's021915942']
[9028.0, 9120.0]
[23.0, 30.0]
[172, 165]
p03428
u163320134
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
['import math\npi=3.141592657589793238462643383279\n\n#quoted from https://qiita.com/kkttm530/items/d6ca372491b75baeac3c\ndef signed_area(p1, p2, p3):\n \n\n area = (((p2[0] - p1[0]) * (p3[1] - p1[1])) - ((p3[0] - p1[0]) * (p2[1] - p1[1]))) / 2\n return area\n\n\ndef convex_hull(p_list):\n \n\n p_sort = []\n for i in p_list:\n p_sort.append(i[0])\n\n \n min_index = p_sort.index(min(p_sort))\n min_p = p_list.pop(min_index)\n p_list.insert(0, min_p)\n\n \n p_length = len(p_list)\n count = 0\n index = 0\n while True:\n count += 1\n index += 1\n\n area_sign = signed_area(p_list[0], p_list[index], p_list[index + 1])\n\n \n if area_sign < 0:\n p_list[index], p_list[index + 1] = p_list[index + 1], p_list[index]\n count = 0\n\n if count == p_length - 1:\n break\n\n if index == p_length - 2:\n index = 0\n\n \n index = -1\n count = 0\n while True:\n index += 1\n count += 1\n\n area_sign = signed_area(p_list[index], p_list[index + 1], p_list[index + 2])\n if area_sign < 0:\n del p_list[index + 1]\n count = 0\n\n if count == len(p_list):\n break\n\n if index >= len(p_list) - 3:\n index = -1\n return p_list\n\ndef getVectorLength(x,y):\n return (x**2+y**2)**0.5\n\ndef dotProduct(u,v):\n return u[0]*v[0]+u[1]*v[1]\n\ndef vectorsAngle(u,v):\n l1=getVectorLength(u[0],u[1])\n l2=getVectorLength(v[0],v[1])\n cosTheta=dotProduct(u,v)/(l1*l2)\n theta=math.acos(cosTheta)\n return 180*theta/pi\n \nn=int(input())\narr=[]\nfor _ in range(n):\n x,y=map(int,input().split())\n arr.append((x,y))\narr2=convex_hull(arr[:])\nans=[0]*n\nif n==2:\n print(0.5)\n print(0.5)\nelse:\n for i in range(n):\n pos=arr[i]\n if pos not in arr2:\n continue\n else:\n idx=arr2.index(pos)\n pos1=arr2[idx-1]\n pos2=arr2[(idx+1)%len(arr2)]\n x1=pos[0]-pos1[0]\n y1=pos[1]-pos1[1]\n x2=pos2[0]-pos[0]\n y2=pos2[1]-pos[1]\n angle=math.atan2(x1*y2-x2*y1,x1*x2+y1*y2)\n ans[i]=angle/(2*pi)\n for i in range(n):\n print(ans[i])', 'import math\npi=3.141592657589793238462643383279\n\n#quoted from https://atcoder.jp/contests/agc021/submissions/2436528\ndef cross(C, A, B):\n return (C[0] - A[0])*(C[1] - B[1]) - (C[1] - A[1])*(C[0] - B[0])\n\ndef convex_hull(P):\n P.sort()\n Q = []\n for p in P:\n while 1 < len(Q) and cross(Q[-2], Q[-1], p) >= 0:\n Q.pop()\n Q.append(p)\n k = len(Q)\n for p in reversed(P[:-1]):\n while k < len(Q) and cross(Q[-2], Q[-1], p) >= 0:\n Q.pop()\n Q.append(p)\n return Q\n\nn=int(input())\narr=[]\nfor _ in range(n):\n x,y=map(int,input().split())\n arr.append((x,y))\narr2=convex_hull(arr[:])[:-1]\nans=[0]*n\nif n==2:\n print(0.5)\n print(0.5)\nelse:\n for i in range(n):\n pos=arr[i]\n if pos not in arr2:\n continue\n else:\n idx=arr2.index(pos)\n pos1=arr2[idx-1]\n pos2=arr2[(idx+1)%len(arr2)]\n x1=pos[0]-pos1[0]\n y1=pos[1]-pos1[1]\n x2=pos2[0]-pos[0]\n y2=pos2[1]-pos[1]\n angle=abs(math.atan2(x1*y2-x2*y1,x1*x2+y1*y2))\n ans[i]=angle/(2*pi)\n for i in range(n):\n print(ans[i])']
['Runtime Error', 'Accepted']
['s288410401', 's855990665']
[3444.0, 3188.0]
[28.0, 20.0]
[2450, 1078]
p03428
u467736898
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
['import math\nN = int(input())\nH = [list(map(int, input().split())) for i in range(N)]\nP = [[0, 2*math.pi] for i in range(N)]\nfor i in range(N):\n for j in range(N):\n if i==j:\n continue\n rad = math.atan2(H[i][1]-H[j][1], H[i][0]-H[j][0])\n mi = (rad - math.pi/2) % (2*math.pi)\n ma = (rad + math.pi/2) % (2*math.pi)\n if ma > mi:\n if P[i][0] >= P[i][1]:\n if mi < P[i][1]:\n P[i] = [mi, P[i][1]]\n elif ma > P[i][0]:\n P[i] = [P[i][0], ma]\n else:\n P[i] = [0, 0]\n break\n else:\n P[i] = [max(P[i][0], mi), min(P[i][1], ma)]\n if P[i][0] >= P[i][1]:\n P[i] = [0, 0]\n break\n else:\n if P[i][0] >= P[i][1]:\n P[i] = [max(P[i][0], mi), min(P[i][1], ma)]\n elif P[i] == [0, 2*math.pi]:\n P[i] = [mi, ma]\n else:\n if mi < P[i][1]:\n if mi < P[i][0]:\n continue\n else:\n P[i] = [mi, P[i][1]]\n elif ma > P[i][0]:\n if ma > P[i][1]:\n continue\n else:\n P[i] = [P[i][0], ma]\n else:\n P[i] = [0, 0]\n break\nprint(P)\nfor p in P:\n print((p[1]-p[0]) / (2*math.pi) % 1)\n', 'import math\nN = int(input())\nH = [list(map(int, input().split())) for i in range(N)]\nP = [[0, 2*math.pi] for i in range(N)]\nfor i in range(N):\n for j in range(N):\n if i==j:\n continue\n rad = math.atan2(H[i][1]-H[j][1], H[i][0]-H[j][0])\n mi = (rad - math.pi/2) % (2*math.pi)\n ma = (rad + math.pi/2) % (2*math.pi)\n if ma > mi:\n if P[i][0] >= P[i][1]:\n if mi < P[i][1]:\n P[i] = [mi, P[i][1]]\n elif ma > P[i][0]:\n P[i] = [P[i][0], ma]\n else:\n P[i] = [0, 0]\n break\n else:\n P[i] = [max(P[i][0], mi), min(P[i][1], ma)]\n if P[i][0] >= P[i][1]:\n P[i] = [0, 0]\n break\n else:\n if P[i][0] >= P[i][1]:\n P[i] = [max(P[i][0], mi), min(P[i][1], ma)]\n elif P[i] == [0, 2*math.pi]:\n P[i] = [mi, ma]\n else:\n if mi < P[i][1]:\n if mi < P[i][0]:\n continue\n else:\n P[i] = [mi, P[i][1]]\n elif ma > P[i][0]:\n if ma > P[i][1]:\n continue\n else:\n P[i] = [P[i][0], ma]\n else:\n P[i] = [0, 0]\n break\nfor p in P:\n print((p[1]-p[0]) / (2*math.pi) % 1)\n']
['Wrong Answer', 'Accepted']
['s795884908', 's583156682']
[3192.0, 3316.0]
[43.0, 43.0]
[1511, 1502]
p03428
u637175065
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
["import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n = I()\n a = [LI() for _ in range(n)]\n count = 100000\n k = math.pi * 2 / count\n l = 10**10\n s = 1 / count\n r = [0] * n\n for i in range(count):\n t = k * i\n x = int(math.sin(t) * l)\n y = int(math.cos(t) * l)\n\n mi = 0\n mm = inf ** 2\n for j in range(n):\n tm = pow(x-a[j][0], 2) + pow(y-a[j][1], 2)\n if mm > tm:\n mm = tm\n mi = j\n r[mi] += s\n\n return '\\n'.join(map(str,r))\n\n\nprint(main())\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef ccw(a, b, c):\n ax = b[0] - a[0]\n ay = b[1] - a[1]\n bx = c[0] - a[0]\n by = c[1] - a[1]\n t = ax*by - ay*bx;\n if t > 0:\n return 1\n if t < 0:\n return -1\n if ax*bx + ay*by < 0:\n return 2\n if ax*ax + ay*ay < bx*bx + by*by:\n return -2\n return 0\n\ndef convex_hull(ps):\n n = len(ps)\n k = 0\n ps.sort()\n ch = [[-1,-1] for _ in range(n*2)]\n for i in range(n):\n while k >= 2 and ccw(ch[k-2], ch[k-1], ps[i]) <= 0:\n k -= 1\n ch[k] = ps[i]\n k += 1\n t = k + 1\n for i in range(n-2,-1,-1):\n while k >= t and ccw(ch[k-2], ch[k-1], ps[i]) <= 0:\n k -= 1\n ch[k] = ps[i]\n k += 1\n ch = ch[:k-1]\n return ch\n\ndef radian(a, b):\n return math.atan2(b[1]-a[1], b[0]-a[0])\n\ndef main():\n n = I()\n a = [LI() + [_] for _ in range(n)]\n t = convex_hull(a)\n l = len(t)\n r = [0] * n\n if l == 2:\n r[t[0][2]] = 0.5\n r[t[1][2]] = 0.5\n else:\n for i in range(l):\n r1 = radian(t[i], t[i-1])\n r2 = radian(t[i], t[(i+1) % l])\n k = r2 - r1\n while k < 0:\n k += math.pi * 2\n e = (k-math.pi) / math.pi / 2\n r[t[i][2]] = e\n\n return '\\n'.join(map(str,r))\n\n\nprint(main())\n"]
['Wrong Answer', 'Accepted']
['s813197879', 's818494560']
[5452.0, 5972.0]
[2104.0, 50.0]
[1194, 1969]
p03428
u670180528
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
['from scipy.spatial import ConvexHull as CH\nimport numpy as np\nnorm=np.linalg.norm\nn,*t=map(int,open(0).read().split())\na=np.reshape(t,(n,2))\nh=CH(a).vertices\nl=len(h)\nfor i in range(n):\n\tif i in h:\n\t\tj=np.where(h==i)[0]\n\t\tf,s,t=a[h[j-1]],a[i],a[h[(j+1)%l]]\n\t\tprint(np.arccos(np.inner(t-s,s-f)/(norm(t-s)*norm(s-f)))[0,0]/(2*np.pi))\n\telse:\n\t\tprint(0.)', 'from scipy.spatial import ConvexHull as CH\nimport numpy as np\nnorm=np.linalg.norm\nn,*t=map(int,open(0).read().split())\na=np.reshape(t,(n,2))\ntry:\n\th = CH(a).vertices\nexcept:\n\ta=a-10**6\n\tif np.all(a[:,0]==a[0,0]):\n\t\ta=np.fliplr(a)\n\tb=a[:,0]\n\tM=np.argmax(b)\n\tm=np.argmin(b)\n\tfor i in range(n):\n\t\tprint(0.5*(i in (m,M)))\n\texit()\nl=len(h)\nfor i in range(n):\n\tif i in h:\n\t\tj=np.where(h==i)[0]\n\t\tf,s,t=a[h[j-1]],a[i],a[h[(j+1)%l]]\n\t\tprint(np.arccos(np.inner(t-s,s-f)/(norm(t-s)*norm(s-f)))[0,0]/(2*np.pi))\n\telse:\n\t\tprint(0.)']
['Runtime Error', 'Accepted']
['s278175480', 's031653490']
[16916.0, 16816.0]
[191.0, 214.0]
[350, 518]
p03428
u766684188
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
['#021-B\nimport sys\ninput=sys.stdin.readline\nfrom math import atan2,pi\nfrom operator import itemgetter\n\ndef InnerProduct(V0,V1):\n x0,y0=V0\n x1,y1=V1\n return x0*x1+y0*y1\ndef CrossProduct(V0,V1):\n x0,y0=V0\n x1,y1=V1\n return x0*y1-x1*y0\ndef angle(P0,P1):\n x0,y0=P0\n x1,y1=P1\n return atan2(y1-y0,x1-x0)\ndef counterclockwise(P0,P1,P2):\n V0,V1=(P1[0]-P0[0],P1[1]-P0[1]),(P2[0]-P0[0],P2[1]-P0[1])\n return CrossProduct(V0,V1)>0\n\ndef GrahamScan(P):\n V=sorted(P,key=itemgetter(1))\n V0=V[0]\n V=sorted(V[1:], key=lambda p: angle(p,V0))+V[:1]\n convex=V[-1:]+V[:1]\n last_x,last_y=convex[-1]\n for p in V[1:]:\n while not counterclockwise(convex[-2],convex[-1],p):\n convex.pop()\n convex.append(p)\n last_x,last_y=p\n return convex[:-1]\n\nn=int(input())\nP=[tuple(map(int,input().split())) for _ in range(n)]\nd={p: i for i,p in enumerate(P)}\nans=[0]*n\nCH=GrahamScan(P)*2\nfor (x0,y0),(x1,y1),(x2,y2) in zip(CH,CH[1:],CH[2:]):\n V0,V1=(x0-x1,y0-y1),(x2-x1,y2-y1)\n ans[d[(x1,y1)]]=(pi+atan2(CrossProduct(V0,V1),InnerProduct(V0,V1)))/(2*pi)\nfor a in ans:\n print(a)', 'import sys\ninput=sys.stdin.readline\nfrom math import atan2,pi\n\ndef InnerProduct(V0,V1):\n x0,y0=V0\n x1,y1=V1\n return x0*x1+y0*y1\ndef CrossProduct(V0,V1):\n x0,y0=V0\n x1,y1=V1\n return x0*y1-x1*y0\ndef clockwise(P0,P1,P2):\n V0,V1=(P1[0]-P0[0],P1[1]-P0[1]),(P2[0]-P0[0],P2[1]-P0[1])\n return CrossProduct(V0,V1)<0\n\ndef MonotoneChain(V):\n upper,lower=[],[]\n P=sorted(V)\n for p in P:\n while len(lower)>1 and (not clockwise(lower[-2],lower[-1],p)):\n lower.pop()\n lower.append(p)\n for p in P[::-1]:\n while len(upper)>1 and (not clockwise(upper[-2],upper[-1],p)):\n upper.pop()\n upper.append(p)\n return lower[:-1]+upper[:-1]\n\nn=int(input())\nP=[tuple(map(int,input().split())) for _ in range(n)]\nd={p: i for i,p in enumerate(P)}\nans=[0]*n\nCH=MonotoneChain(P)\nCH+=[CH[0],CH[1]]\nfor (x0,y0),(x1,y1),(x2,y2) in zip(CH,CH[1:],CH[2:]):\n V0,V1=(x0-x1,y0-y1),(x2-x1,y2-y1)\n ans[d[(x1,y1)]]=(pi-atan2(CrossProduct(V0,V1),InnerProduct(V0,V1)))/(2*pi)\nfor a in ans:\n print(a)']
['Runtime Error', 'Accepted']
['s201404080', 's249921029']
[3316.0, 3188.0]
[23.0, 18.0]
[1130, 1049]
p03428
u875291233
2,000
262,144
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest Euclidean distance from the point, and fall into that hole. If there are multiple such holes, the hole with the smallest index will be chosen. For every i (1 \leq i \leq N), find the probability that Snuke falls into the i-th hole. Here, the operation of randomly choosing a point from the interior of a circle of radius R is defined as follows: * Pick two real numbers x and y independently according to uniform distribution on [-R,R]. * If x^2+y^2\leq R^2, the point (x,y) is chosen. Otherwise, repeat picking the real numbers x,y until the condition is met.
['import math\n\nN=int(input())\n\nPI = math.pi\n\nX=[]\nY=[]\nfor i in range(N):\n x,y=[int(i) for i in input().split()]\n X.append(x)\n Y.append(y)\n\nfor i in range(N):\n kakudo = [math.atan2(Y[i]-Y[j],X[i]-X[j]) for j in range(N) if j != i]\n kakudo.sort()\n print(kakudo)\n kmax = 0\n if N == 2:\n kmax = 2*PI\n else:\n for j in range(N-2):\n kmax = max(kmax,kakudo[j+1] - kakudo[j])\n kmax = max(kmax, kakudo[0] + 2*PI - kakudo[N-2])\n print(max(0,kmax-PI)/(2*PI))\n\n', 'import math\n\nN=int(input())\n\nPI = math.pi\n\nX=[]\nY=[]\nfor i in range(N):\n x,y=[int(i) for i in input().split()]\n X.append(x)\n Y.append(y)\n\nfor i in range(N):\n kakudo = [math.atan2(Y[i]-Y[j],X[i]-X[j]) for j in range(N) if j != i]\n kakudo.sort()\n# print(kakudo)\n kmax = 0\n if N == 2:\n kmax = 2*PI\n else:\n for j in range(N-2):\n kmax = max(kmax,kakudo[j+1] - kakudo[j])\n kmax = max(kmax, kakudo[0] + 2*PI - kakudo[N-2])\n print(max(0,kmax-PI)/(2*PI))\n\n']
['Wrong Answer', 'Accepted']
['s161050536', 's061888923']
[3316.0, 3188.0]
[44.0, 34.0]
[535, 536]
p03431
u541055501
2,000
262,144
In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage. A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules: * A Snuke Chameleon that is blue will change its color to red when the number of red balls it has eaten becomes strictly larger than the number of blue balls it has eaten. * A Snuke Chameleon that is red will change its color to blue when the number of blue balls it has eaten becomes strictly larger than the number of red balls it has eaten. Initially, every Snuke Chameleon had not eaten anything. Ringo fed them by repeating the following process K times: * Grab either a red ball or a blue ball. * Throw that ball into the cage. Then, one of the chameleons eats it. After Ringo threw in K balls, all the chameleons were red. We are interested in the possible ways Ringo could have thrown in K balls. How many such ways are there? Find the count modulo 998244353. Here, two ways to throw in balls are considered different when there exists i such that the color of the ball that are thrown in the i-th throw is different.
['n,k,p=map(int,input().split()),998244353\nr=range\nf=[1]\nfor i in r(k):f+=[-~i*f[i]]\nprint(sum(f[-1]*pow(f[i]*f[-1-i],-1,p)for i in r(n-1,k))%p)', 'n,k=map(int,input().split())\np=998244353\nf=[1]\nfor i in range(k):f+=[-~i*f[i]%p]\nprint(sum(f[-2]*pow(f[i]*f[-2-i],-1,p)for i in range(n-1,k))%p)']
['Runtime Error', 'Accepted']
['s608766684', 's227796792']
[9016.0, 28860.0]
[27.0, 1050.0]
[142, 144]
p03451
u021151166
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['#1st arg is the how far from the most upper side\n#2nd arg is the how far from the most left side\n#right means +1 in terms of x-axis\n#upper means -1 in terms of y-axis\n\ndef Right(position):\n\tposition[1] += 1\n\ndef Down(position):\n\tposition[0] += 1 \n\ndef Collect(position,candy):\n\tx = position[0]\n\ty = position[1]\n\ttotal = 0\n\ttotal += candy[x][y]\n\tcandy[x][y] = 0\n\treturn total\n\nN = int(input())\ncandy = []\nwhile True:\n try:\n candy.append(list(map(int,input().split())))\n except:\n break;\nposition = [0,0]\nscore = 0\nmax_score = 0\nfor t in range(N):\n\tscore = 0\n\tposition[0] = 0\n\tposition[1] = 0\n\tfor i in range(N):\n\t\tif t == i:\n\t\t\tDown(position)\n\t\t\tscore += Collect(position,candy)\n\t\tif i < N - 1:\t\n\t\t\tRight(position)\n\t\t\tscore += Collect(position,candy)\n\tif max_score < score:\n\t\tmax_score = score\nprint(max_score)\n\n\n\n', '#1st arg is the how far from the most upper side\n#2nd arg is the how far from the most left side\n#right means +1 in terms of x-axis\n#upper means -1 in terms of y-axis\n\ndef Right(position):\n\tposition[1] += 1\n\ndef Down(position):\n\tposition[0] += 1 \n\ndef Collect(position,candy):\n\tx = position[0]\n\ty = position[1]\n\ttotal = 0\n\ttotal += candy[x][y]\n\treturn total\n\nN = int(input())\ncandy = []\nwhile True:\n try:\n candy.append(list(map(int,input().split())))\n except:\n break;\nposition = [0,0]\nscore = 0\nmax_score = 0\nk = 0\nfor t in range(N):\n\tscore = candy[0][0]\n\tposition[0] = 0\n\tposition[1] = 0\n\tfor i in range(N):\n\t\tif t == i:\n\t\t\tDown(position)\n\t\t\tscore += Collect(position,candy)\n\t\tif i < N - 1:\t\n\t\t\tRight(position)\n\t\t\tscore += Collect(position,candy)\n\tif max_score < score:\n\t\tmax_score = score\n\t\tk = t\nprint(max_score)\n\n\n']
['Wrong Answer', 'Accepted']
['s788336409', 's531352026']
[3064.0, 3064.0]
[25.0, 23.0]
[832, 838]
p03451
u075012704
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['N, M = map(int, input().split())\nLRD = [list(map(int, input().split())) for i in range(M)]\n \n \nclass WeightedUnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n + 1)\n self.weight = [0] * (n+1)\n \n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.weight[x] += self.weight[self.par[x]]\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n \n \n def weighting(self, x):\n self.find(x)\n return self.weight[x]\n \n \n def union(self, x, y, w):\n w -= self.weighting(x)\n w += self.weighting(y)\n x = self.find(x)\n y = self.find(y)\n \n if self.rank[x] < self.rank[y]:\n self.par[x] = y\n else:\n w = -w\n self.weight[y] = w\n self.par[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n \n \n def same(self, x, y):\n return self.find(x) == self.find(y)\n \n \n def diff(self, x, y):\n return abs(self.weighting(x) - self.weighting(y))\n \n \nwuf = WeightedUnionFind(N)\nfor l, r, d in LRD:\n if wuf.same(l, r):\n if wuf.diff(l, r) != d:\n print("No")\n break\n else:\n wuf.union(l, r, d)\nelse:\n print("Yes")', 'N = int(input())\nA = [list(map(int, input().split())) for i in range(2)]\n\nans = 0\nfor i in range(N):\n ans = max(ans, sum(A[0][:i+1])+sum(A[1][i:]))\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s349937037', 's283306019']
[3188.0, 2940.0]
[18.0, 17.0]
[1429, 163]
p03451
u077291787
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['\ndef main():\n N = int(input())\n A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(2))\n dp = [0] * N # dp[i] := score of upside [:i+1] and downside [i:]\n for i in range(N):\n dp[0] = sum(A[0][: i + 1]) + sum(A[1][i:])\n print(max(dp))\n\n\nif __name__ == "__main__":\n main()', '\ndef main():\n N = int(input())\n A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(2))\n ans = {sum(A[0][: i + 1]) + sum(A[1][i:]) for i in range(N)}\n print(max(ans))\n\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s822824201', 's591927333']
[3060.0, 3060.0]
[18.0, 18.0]
[340, 262]
p03451
u106778233
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['N=int(input())\nA=[list(map(int,input().split())) for _ in range(2)]\n\ntemp=0\nfor i in range(n):\n temp=max(temp, sum(A[0][:i+1])+sum(A[1][i:]))\n\nprint(ans)', 'N=int(input())\nA=[list(map(int,input().split())) for _ in range(2)]\n\ntemp=0\nfor i in range(N):\n temp=max(temp, sum(A[0][:i+1])+sum(A[1][i:]))\n\nprint(temp)']
['Runtime Error', 'Accepted']
['s591388921', 's781750493']
[3060.0, 3060.0]
[18.0, 19.0]
[156, 157]
p03451
u131406572
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nCandies=[]\nfor i in range(n):\n Candies.appned(sum(a[:i+1])+sum(b[i+1:])\nprint(max(Candies))', 'n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nCandies=[]\nfor i in range(n):\n Candies.append(sum(a[:i+1])+sum(b[i:]))\nprint(max(Candies))']
['Runtime Error', 'Accepted']
['s027991376', 's633769782']
[2940.0, 3060.0]
[17.0, 20.0]
[175, 174]
p03451
u505327012
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['def find_max(n, grid):\n def helper(idx, cur_max, down):\n if n > (idx + 1):\n if down:\n return helper(idx + 1, cur_max + grid[1][idx], down)\n else:\n return max(helper(idx + 1, cur_max + grid[1][idx], True), helper(idx + 1, cur_max + grid[0][idx + 1], False))\n else:\n return cur_max + grid[1][idx]\n\n return helper(0, grid[0][0], False)\n\nn = int(input())\ncandie_matrix = []\nfor i in range(2):\n row = list(map(int, input().split()))\n if len(row) != n:\n print("wrong inputs")\n return;\n\n candie_matrix.append(row)\n\nfind_max(n,candie_matrix)', 'def find_max(n, grid):\n def helper(idx, cur_max, down):\n if n > (idx + 1):\n if down:\n return helper(idx + 1, cur_max + grid[1][idx], down)\n else:\n return max(helper(idx + 1, cur_max + grid[1][idx], True), helper(idx + 1, cur_max + grid[0][idx + 1], False))\n else:\n return cur_max + grid[1][idx]\n\n return helper(0, grid[0][0], False)\n\nn = int(input())\ncandie_matrix = []\nfor i in range(2):\n row = list(map(int, input().split()))\n if len(row) != n:\n print("wrong inputs")\n\n candie_matrix.append(row)\n\nprint(find_max(n,candie_matrix))\n']
['Runtime Error', 'Accepted']
['s582967534', 's609032729']
[3188.0, 3064.0]
[19.0, 19.0]
[639, 631]
p03451
u626337957
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['N = int(input())\ncandies = [list(map(int, input().split())) for _ in range(2)]\ndp = [[0,0] for _ in range(N)]\ndp[0][0] = candies[0][0]\ndp[1][0] = dp[0][0] + candies[1][0]\nfor i in range(1, N):\n dp[0][i] += dp[0][i-1] + candies[0][i]\n dp[1][i] = max(dp[0][i], dp[1][i-1]) + candies[1][i]\nprint(dp[1][N-1])', 'N = int(input())\ncandies = [list(map(int, input().split())) for _ in range(2)]\ndp = [[0] * (N) for _ in range(2)]\ndp[0][0] = candies[0][0]\ndp[1][0] = dp[0][0] + candies[1][0]\nfor i in range(1, N):\n dp[0][i] = dp[0][i-1] + candies[0][i]\n dp[1][i] = max(dp[0][i], dp[1][i-1]) + candies[1][i]\nprint(dp[1][N-1])\n']
['Runtime Error', 'Accepted']
['s307786777', 's152052630']
[3064.0, 3064.0]
[17.0, 17.0]
[306, 310]
p03451
u751717561
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['N = int(input())\nA = [list(map(int, input().split())) for _ in range(2)]\n\nprint(A)\nv1 = A[0][0]\nv2 = A[1][0] + A[0][0]\n\nif N==1:\n print(v2)\n exit()\n\nfor j in range(1, N):\n v1 += A[0][j]\n v2 = A[1][j] + max(v2, v1)\n\nprint(v2)', 'N = int(input())\nA = [list(map(int, input().split())) for _ in range(2)]\n\nv1 = A[0][0]\nv2 = A[1][0] + v1\n\nif N==1:\n print(v2)\n exit()\n\nfor j in range(1, N):\n v1 += A[0][j]\n v2 = A[1][j] + max(v2, v1)\n\nprint(v2)']
['Wrong Answer', 'Accepted']
['s078313949', 's950142923']
[3064.0, 3064.0]
[17.0, 18.0]
[236, 222]
p03451
u777923818
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['# -*- coding: utf-8 -*-\nimport sys\nsys.setrecursionlimit(10000)\nfrom collections import defaultdict, deque\ndef inpl(): return tuple(map(int, input().split()))\n \nN, M = inpl()\nQ = [inpl() for _ in range(M)]\n \ntree = [[-1, 1] for _ in range(N+1)] # [next, rank]\n \ndef find(i):\n if tree[i][0] == -1:\n group = i\n else:\n group = find(tree[i][0]) \n tree[i][0] = group\n return group\n \ndef unite(x, y):\n px = find(x)\n py = find(y)\n \n if tree[px][1] == tree[py][1]: # rank is same\n tree[py][0] = px\n tree[px][1] += 1\n else:\n if tree[px][1] < tree[py][1]:\n px, py = py, px\n tree[py][0] = px\n \nadj = [[] for _ in range(N+1)] \n \nfor l, r, d in Q:\n if find(l) != find(r):\n unite(l, r)\n adj[l].append([r, d])\n adj[r].append([l, -d])\n \n \nG = set([find(n) for n in range(1, N+1)])\n \nX = [-1 for _ in range(N+1)]\nsearched = [False for _ in range(N+1)]\nres = True\n \nfor g in G:\n X[g] = 0\n Q = deque([g])\n searched[g] = True\n while Q:\n p = Q.popleft()\n for np, d in adj[p]:\n if searched[np]:\n if X[np] != X[p] + d:\n Q = []\n res = False\n break\n else:\n X[np] = X[p] + d\n Q.append(np)\n searched[np] = True\n if not res:\n break\n \nif res:\n print("Yes")\nelse:\n print("No")', '# -*- coding: utf-8 -*-\nfrom itertools import accumulate\ndef inpl(): return tuple(map(int, input().split()))\nN = int(input())\nA = inpl()\nB = inpl()\nres = 0\nfor i in range(N):\n res = max(res, sum(A[:i+1]) + sum(B[i:]))\n\nprint(res)']
['Runtime Error', 'Accepted']
['s507435234', 's529583916']
[3444.0, 3060.0]
[26.0, 50.0]
[1433, 232]
p03451
u933083947
2,000
262,144
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
['N = int(input())\nL1 = map(int, input().split())\nL2 = map(int, input().split())\nP1 = L1[:]\nP2 = L2[:]\nfor i in range(1, N):\n P1[i] += P1[i-1]\nfor j in range(N-1, -1, -1):\n P2[j] += P2[j+1]\nL3 = [0]*N\nfor k in range(N):\n L3[k] = P1[k]+P2[k]\nprint(max(L3))\n \n \n \n', 'N = int(input())\nL1 = [x for x in map(int, input().split())]\nL2 = [x for x in map(int, input().split())]\nP1 = L1[:]\nP2 = L2[:]\nfor i in range(1, N):\n P1[i] += P1[i-1]\nfor j in range(N-2, -1, -1):\n P2[j] += P2[j+1]\nL3 = [0]*N\nfor k in range(N):\n L3[k] = P1[k]+P2[k]\nprint(max(L3))']
['Runtime Error', 'Accepted']
['s837592665', 's932932276']
[3064.0, 3064.0]
[17.0, 17.0]
[266, 282]
p03452
u029169777
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["from collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\n\nN,M=map(int,input().split())\nGraph=[[] for i in range(N)]\nfor i in range(M):\n L,R,D=map(int,input().split())\n Graph[L-1].append(R-1,D)\n Graph[R-1].append(L-1,-D)\nvisit=[False]*N\ndist=[0]*N\n\nfor i in range(N):\n if not visit[i]:\n visit[i]=True\n A=deque()\n A.append(i)\n while A:\n x=A.pop()\n for y,d in Graph[x]:\n if visit[y] and dist[y]!=d+dist[x]\n \tprint('No')\n \texit()\n elif not visit[y]:\n visit[y]=True\n A.append(y)\n dist[y]=d+dist[x]\nprint('Yes')", "from collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\n \nN,M=map(int,input().split())\nGraph=[[] for i in range(N)]\nfor i in range(M):\n L,R,D=map(int,input().split())\n Graph[L-1].append((R-1,D))\n Graph[R-1].append((L-1,-D))\nvisit=[False]*N\ndist=[0]*N\n \n\nfor i in range(N):\n if not visit[i]:\n visit[i]=True\n A=deque()\n A.append(i)\n while A:\n x=A.pop()\n for y,d in Graph[x]:\n if visit[y] and (dist[y]!=d+dist[x]):\n print('No')\n exit()\n elif not visit[y]:\n visit[y]=True\n A.append(y)\n dist[y]=d+dist[x]\nprint('Yes')"]
['Runtime Error', 'Accepted']
['s635143255', 's172483127']
[3064.0, 67100.0]
[17.0, 1265.0]
[601, 611]
p03452
u047668580
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['N,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (i,i)\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n \n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print("No")\n exit()\nprint("Yes")', 'from collections import defaultdict\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (i,i)\n visited[i] = True\n (n,m) = ( - inf, inf)\n for j,d in edges[i]:\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\nfor i in range(N):\n \n (n,m) = walk(i)\n if m -n > 10 ** 9:\n print("No")\n exit()\nprint("Yes")', 'N,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (i,i)\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n \n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print("No")\n exit()\nprint("Yes")', 'from sys import exit, setrecursionlimit\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict\nfrom bisect import bisect\n \ndef read():\n return int(input())\n \ndef reads():\n return [int(x) for x in input().split()]\n \nsetrecursionlimit(1000000)\nINF = 10**10\n \n(N, M) = reads()\n \nedges = [[] for _ in range(N)]\n \nfor _ in range(M):\n (L, R, D) = reads()\n (L, R) = (L-1, R-1)\n edges[L].append((R, D))\n edges[R].append((L, -D))\n \nvisited = [False] * N\nplace = [None] * N\n \ndef walk(i):\n if visited[i]:\n return (place[i], place[i])\n visited[i] = True\n (m, M) = (INF, -INF)\n for (j, d) in edges[i]:\n if visited[j] and place[j] != place[i] + d:\n # print("v = ", visited)\n # print("p = ", place)\n print("No")\n exit()\n place[j] = place[i] + d\n (x, y) = walk(j)\n (m, M) = (min(m, x), max(M, y))\n return (m, M)\n \nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n (m, M) = walk(i)\n if M - m > 10**9:\n # print("(m, M) = ", (m, M))\n print("No")\n exit()\n \nprint("Yes")']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s905937747', 's974792218', 's979398632', 's735757944']
[67988.0, 68100.0, 68004.0, 131816.0]
[1146.0, 1249.0, 1246.0, 1844.0]
[807, 764, 807, 1153]
p03452
u075012704
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['N, M = map(int, input().split())\nLRD = [list(map(int, input().split())) for i in range(M)]\n\n\nclass WeightedUnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n + 1)\n self.weight = [0] * (n+1)\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.weight[x] += self.weight[self.par[x]]\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def weighting(self, x):\n self.find(x)\n return self.weight[x]\n\n \n def union(self, x, y, w):\n w -= self.weighting(x)\n w += self.weighting(y)\n x = self.find(x)\n y = self.find(y)\n \n if self.rank[x] < self.rank[y]:\n self.weight[x] = w\n self.par[x] = y\n else:\n w = -w\n self.weight[y] = w\n self.par[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n \n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n \n def diff(self, x, y):\n return self.weighting(x) - self.weighting(y)\n\n\nwuf = WeightedUnionFind(N)\nfor l, r, d in LRD:\n if wuf.same(l, r):\n print(wuf.diff(l,r))\n if wuf.diff(l, r) != d:\n print("No")\n break\n else:\n wuf.union(l, r, d)\nelse:\n print("Yes")\n\n', 'N, M = map(int, input().split())\nLRD = sorted([list(map(int, input().split())) for i in range(M)])\n\npeople = [0] * (N+1)\nfor l, r, d in LRD:\n if (people[l]!=0) & (people[r]!=0):\n if abs(people[r]) + abs(people[l]) != d:\n print("No")\n break\n else:\n people[l] -= d\n people[r] += d\nelse:\n print("Yes")\n\n\n', 'N, M = map(int, input().split())\nLRD = [list(map(int, input().split())) for i in range(M)]\n\n\nclass WeightedUnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n + 1)\n self.weight = [0] * (n+1)\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.weight[x] += self.weight[self.par[x]]\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n def weighting(self, x):\n self.find(x)\n return self.weight[x]\n\n \n def union(self, x, y, w):\n w -= self.weighting(x)\n w += self.weighting(y)\n x = self.find(x)\n y = self.find(y)\n\n if self.rank[x] < self.rank[y]:\n self.par[x] = y\n else:\n w = -w\n self.weight[y] = w\n self.par[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n \n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n \n def diff(self, x, y):\n return abs(self.weighting(x) - self.weighting(y))\n\n\nwuf = WeightedUnionFind(N)\nfor l, r, d in LRD:\n if wuf.same(l, r):\n print(wuf.diff(l, r))\n if wuf.diff(l, r) != d:\n print("No")\n break\n else:\n wuf.union(l, r, d)\nelse:\n print("Yes")\n', 'N, M = map(int, input().split())\nLRD = [list(map(int, input().split())) for i in range(M)]\nLRD.sort(key=lambda x:x[0]or x[1])\n\npeople = [0] * (N+1)\npeetru = [False] * (N+1)\nfor l, r, d in LRD:\n if (peetru[l]) & (peetru[r]):\n if abs(people[r]) + abs(people[l]) != d:\n print("No")\n break\n else:\n peetru[l] = True\n peetru[r] = True\n people[l] -= d\n people[r] += d\nelse:\n print("Yes")\n\n\n', 'class WeightedUnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n \n self.weight = [0] * (n+1)\n\n \n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n y = self.find(self.par[x])\n \n self.weight[x] += self.weight[self.par[x]]\n self.par[x] = y\n return y\n\n \n def weighting(self, x):\n self.find(x)\n return self.weight[x]\n\n \n def union(self, x, y, w):\n rx = self.find(x)\n ry = self.find(y)\n \n if self.rank[rx] < self.rank[ry]:\n self.par[rx] = ry\n self.weight[rx] = w - self.weight[x] + self.weight[y]\n \n else:\n self.par[ry] = rx\n self.weight[ry] = -w - self.weight[y] + self.weight[x]\n if self.rank[rx] == self.rank[ry]:\n self.rank[rx] += 1\n\n \n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n \n def diff(self, x, y):\n return self.weight[x] - self.weight[y]\n\n\nN, M = map(int, input().split())\nwuf = WeightedUnionFind(N)\nfor i in range(M):\n l, r, d = map(int, input().split())\n if wuf.same(l, r):\n if wuf.diff(l, r) != d:\n print("No")\n break\n else:\n wuf.union(l, r, d)\nelse:\n print("Yes")']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s051050641', 's378755578', 's468647015', 's855404944', 's545761479']
[58460.0, 55196.0, 58452.0, 55924.0, 10236.0]
[892.0, 1095.0, 910.0, 896.0, 1197.0]
[1484, 353, 1450, 449, 1615]
p03452
u137226361
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0]*n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x,y,z):\n s, ws = find(x)\n t, wt = find(y)\n #print(ws, wt)\n if s==t:\n if ws - wt == z:\n pass\n else:\n print('No')\n exit(0)\n else:\n par[s] = t\n diff[s] = z\n\nunites =[]\n\nfor _ in range(m):\n l,r,d = map(int, input().split())\n unites.append((l,r,d))\n unite(l-1,r-1,d)\n#print(unites)\n\nfor x, y, z in unites:\n unite(x-1, y-1, d)\n\nprint('Yes')", "n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0]*n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x,y,z):\n s, ws = find(x)\n t, wt = find(y)\n #print(ws, wt)\n if s==t:\n if ws - wt == z:\n pass\n else:\n print('Yes')\n exit(0)\n else:\n par[s] = t\n diff[s] = z\n\nfor _ in range(m):\n l,r,d = map(int, input().split())\n unite(l-1,r-1,d)\n\nprint('No')", "n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0]*n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x,y,z):\n s, ws = find(x)\n t, wt = find(y)\n #print(ws, wt)\n if s==t:\n if ws - wt == z:\n pass\n else:\n print('No')\n exit(0)\n else:\n par[s] = t\n diff[s] = z\n\nunites =[]\nfor _ in range(m):\n l,r,d = map(int, input().split())\n unites.append((l,r,d))\n unite(l-1,r-1,d)\nfor x, y, z in unites:\n unites(x-1, y-1, d)\n\nprint('Yes')", "n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0] * n\n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x, y, z):\n s, ws = find(x)\n t, wt = find(y)\n # print(ws, wt)\n if s == t:\n if ws - wt == z:\n pass\n else:\n print('No')\n exit(0)\n else:\n if ws < z + wt:\n par[s] = t\n diff[s] = z + wt - ws\n else:\n par[t] = s\n diff[t] = ws - z - wt\n\n\nfor _ in range(m):\n l, r, d = map(int, input().split())\n unite(l - 1, r - 1, d)\n\nprint('Yes')"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s138937905', 's656663912', 's940053601', 's530980768']
[21252.0, 14656.0, 21292.0, 14980.0]
[213.0, 170.0, 187.0, 639.0]
[666, 565, 650, 695]
p03452
u197457087
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["class WeightedUnionFind():\n def __init__(self, n):\n self.par = [i for i in range(n)]\n self.rank = [0 for i in range(n)]\n \n self.diff_weight = [0 for i in range(n)]\n\n def find(self, x):\n if self.par[x] == x:\n return x\n \n root = self.find(self.par[x])\n self.diff_weight[x] += self.diff_weight[self.par[x]]\n self.par[x] = root\n return self.par[x]\n\n def weight(self, x):\n \n self.find(x)\n return self.diff_weight[x]\n\n def diff(self, x, y):\n \n return self.weight(y) - self.weight(x)\n\n def unite(self, x, y, w):\n \n \n w += self.weight(x); w -= self.weight(y)\n x = self.find(x); y = self.find(y)\n if x == y:\n return\n if self.rank[x] < self.rank[y]:\n \n self.par[x] = y\n w = -w\n self.diff_weight[x] = w\n elif self.rank[y] < self.rank[x]:\n self.par[y] = x\n self.diff_weight[y] = w\n else:\n self.par[y] = x\n self.rank[x] += 1\n self.diff_weight[y] = w\n \nN, M = map(int, input().split())\nUF = WeightedUnionFind(N)\nfor i in range(M):\n L, R, D = map(int, input().split())\n L -= 1\n R -= 1\n \n if UF.find(L) == UF.find(R):\n if UF.diff(L, R) != d:\n print('No')\n break\n else:\n UF.unite(L, R, D)\nelse:\n print('Yes')", "class WeightedUnionFind():\n def __init__(self, n):\n self.par = [i for i in range(n)]\n self.rank = [0 for i in range(n)]\n \n self.diff_weight = [0 for i in range(n)]\n\n def find(self, x):\n if self.par[x] == x:\n return x\n \n root = self.find(self.par[x])\n self.diff_weight[x] += self.diff_weight[self.par[x]]\n self.par[x] = root\n return self.par[x]\n\n def weight(self, x):\n \n self.find(x)\n return self.diff_weight[x]\n\n def diff(self, x, y):\n \n return self.weight(y) - self.weight(x)\n\n def unite(self, x, y, w):\n \n \n w += self.weight(x); w -= self.weight(y)\n x = self.find(x); y = self.find(y)\n if x == y:\n return\n if self.rank[x] < self.rank[y]:\n \n self.par[x] = y\n w = -w\n self.diff_weight[x] = w\n elif self.rank[y] < self.rank[x]:\n self.par[y] = x\n self.diff_weight[y] = w\n else:\n self.par[y] = x\n self.rank[x] += 1\n self.diff_weight[y] = w\n \nN, M = map(int, input().split())\nUF = WeightedUnionFind(N)\nfor i in range(M):\n L, R, D = map(int, input().split())\n L -= 1\n R -= 1\n \n if UF.find(L) == UF.find(R):\n if UF.diff(L, R) != D:\n print('No')\n break\n else:\n UF.unite(L, R, D)\nelse:\n print('Yes')"]
['Runtime Error', 'Accepted']
['s991052145', 's546128275']
[9508.0, 10024.0]
[381.0, 1594.0]
[1902, 1902]
p03452
u333945892
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["import sys\n\nsys.setrecursionlimit(10**8)\n\ndef find(x):\t\n\tglobal table\n\tglobal diff_weight\n\t\n\tif table[x] == x:\n\t\treturn x\n\telse:\n\t\tdiff_weight[x] += diff_weight[table[x]] \n\t\ttable[x] = find(table[x])\t\n\t\treturn table[x]\n\ndef union(x,y,w):\t\n\tw = w - weight(y) + weight(x) \n\tx = find(x)\t\n\ty = find(y)\n\t\n\tif x == y:\n\t\treturn\n\t\n\tif rank[x] < rank[y]:\n\t\tx,y = y,x\n\t\tw = -w\n\t\n\ttable[y] = x\n\tdiff_weight[y] = w\n\t\n\tif rank[x] == rank[y]:\n\t\t\trank[y] += 1\n\ndef check(x,y): \n\tif find(x) == find(y):\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef weight(x):\n\tfind(x)\t\n\treturn diff_weight[x]\n\t\t\ndef diff(x,y): \n\treturn (weight(y) - weight(x))\n\n\t\t\nN,M = map(int,input().split())\n\ntable = [i for i in range(N)]\t\nrank = [1 for i in range(N)]\t\ndiff_weight = [0 for i in range(N)]\n\n\nfor i in range(M):\n\ta,b,D = (map(int,input().split()))\n\ta -= 1\n\tb -= 1\n\tif check(a,b):\n\t\tif diff(a,b) != D:\n\t\t\tprint ('table',table)\n\t\t\tprint ('weight',diff_weight)\n\t\t\tprint('No')\n\t\t\tsys.exit()\n\telse:\n\t\tunion(a,b,D)\n\tprint ('table',table)\n\tprint ('weight',diff_weight)\n\t\n\t\nprint ('Yes')", "import sys\n\nsys.setrecursionlimit(10**8)\n\ndef find(x):\t\n\tglobal table\n\tglobal diff_weight\n\t\n\tif table[x] == x:\n\t\treturn x\n\telse:\n\t\troot = find(table[x])\n\t\tdiff_weight[x] += diff_weight[table[x]] \n\t\ttable[x] = root\t\n\t\treturn table[x]\n\ndef union(x,y,w):\t\n\tw = w - weight(y) + weight(x) \n\tx = find(x)\t\n\ty = find(y)\n\t\n\tif x == y:\n\t\treturn\n\t\n\tif rank[x] < rank[y]:\n\t\tx,y = y,x\n\t\tw = -w\n\t\n\ttable[y] = x\n\tdiff_weight[y] = w\n\t\n\tif rank[x] == rank[y]:\n\t\t\trank[y] += 1\n\ndef check(x,y): \n\tif find(x) == find(y):\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef weight(x):\n\tfind(x)\t\n\treturn diff_weight[x]\n\t\t\ndef diff(x,y): \n\treturn (weight(y) - weight(x))\n\n\t\t\nN,M = map(int,input().split())\n\ntable = [i for i in range(N)]\t\nrank = [1 for i in range(N)]\t\ndiff_weight = [0 for i in range(N)]\n\n\nfor i in range(M):\n\ta,b,D = (map(int,input().split()))\n\ta -= 1\n\tb -= 1\n\tif check(a,b):\n\t\tif diff(a,b) != D:\n\t\t\tprint('No')\n\t\t\tsys.exit()\n\telse:\n\t\tunion(a,b,D)\n\t\n\t\nprint ('Yes')"]
['Runtime Error', 'Accepted']
['s570147695', 's624596676']
[141636.0, 9920.0]
[1978.0, 1556.0]
[1346, 1250]
p03452
u336193675
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["import sys\nfrom collections import deque\n\nn,m = map(int, input().split())\nadj_list = [[] for i in range(n)]\nfor i in range(m):\n l, r, d = map(int, input().split())\n adj_list[l-1].append((r-1, d))\n adj_list[r-1].append((l-1, -d))\ndef search(start, dist_all):\n q = deque([[start]])\n q_d = deque([0])\n while(len(q) > 0):\n path = q.popleft()\n dist = q_d.popleft()\n w = path[len(path) - 1]\n for x in adj_list[w]:\n if dist_all[x[0]] is None:\n dist_all[x[0]] = dist + x[1]\n new_path = path[:]\n new_path.append(x[0])\n elif dist_all[x[0]] != dist + x[1]:\n return False\n q.append(new_path)\n q_d.append(dist + x[1])\n return True\ndist_all = [None for i in range(n)]\nfor i in range(n):\n if dist_all[i] is None:\n if not search(i, dist_all):\n print('No')\n exit(0)\nprint('Yes')", "import sys\nfrom collections import deque\n\nn,m = map(int, input().split())\nadj_list = [[] for i in range(n)]\nfor i in range(m):\n l, r, d = map(int, input().split())\n adj_list[l-1].append((r-1, d))\n adj_list[r-1].append((l-1, -d))\ndef search(start, dist_all):\n q = deque([start])\n dist_all[i] = 0\n while(len(q) > 0):\n w = q.popleft()\n for x in adj_list[w]:\n if dist_all[x[0]] is None:\n dist_all[x[0]] = dist_all[w] + x[1]\n q.append(x[0])\n elif dist_all[x[0]] != dist_all[w] + x[1]:\n return False\n return True\ndist_all = [None for i in range(n)]\nfor i in range(n):\n if dist_all[i] is None:\n if not search(i, dist_all):\n print('No')\n exit(0)\nprint('Yes')"]
['Wrong Answer', 'Accepted']
['s907342247', 's563229088']
[82244.0, 66256.0]
[1316.0, 1187.0]
[946, 784]
p03452
u572144347
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['import sys\nsys.setrecursionlimit(10**9)\nN,M = map(int, input().split())\nLRD = [ [int(j) for j in input().split()] for _ in range(M)]\n\ndata = [-1] * (N+1)\nrank = [0] * (N+1)\ndiff_weight = [0] * (N+1)\n\ndef root(x):\n if data[x] == x:\n return x\n else:\n r = root(x)\n diff_weight[x] += diff_weight[ data[x] ]\n data[x] = r\n return r\n\ndef weight(x):\n _ = root(x)\n return diff_weight[x]\n\n\ndef diff(x,y):\n return weight(y) - weight(x)\n\ndef merge(x,y,w):\n w += weight(x); w -= weight(y)\n x = root(x)\n y = root(y)\n if x == y: return False\n if rank[x] < rank[y]: x,y = y,x; w = -w\n if rank[x] == rank[y]: rank[x] += 1\n data[y] = x\n diff_weight[y] = w\n return True\n\ndef issame(x,y):\n return root(x) == root(y)\n\nfor i in range(M):\n L,R,D = LRD[i]\n if not issame(L,R):\n merge(L,R,D)\n else:\n if weight(L,R) != D:\n print("No")\n exit(0)\n \nprint("Yes")\n\n \n \n', 'import sys\nsys.setrecursionlimit(10**9)\nN,M = map(int, input().split())\ninput = sys.stdin.readline()\nLRD = [ [int(j) for j in input().split()] for _ in range(M)]\n\ndata = [-1] * (N+1)\nrank = [0] * (N+1)\ndiff_weight = [0] * (N+1)\n\ndef root(x):\n if data[x] == x:\n return x\n else:\n r = root(x)\n diff_weight[x] += diff_weight[ data[x] ]\n data[x] = r\n return r\n\ndef weight(x):\n _ = root(x)\n return diff_weight[x]\n\n\ndef diff(x,y):\n return weight(y) - weight(x)\n\ndef merge(x,y,w):\n w += weight(x); w -= weight(y)\n x = root(x)\n y = root(y)\n if x == y: return False\n if rank[x] < rank[y]: x,y = y,x; w = -w\n if rank[x] == rank[y]: rank[x] += 1\n data[y] = x\n diff_weight[y] = w\n return True\n\ndef issame(x,y):\n return root(x) == root(y)\n\nfor i in range(M):\n L,R,D = LRD[i]\n if not issame(L,R):\n merge(L,R,D)\n else:\n if weight(L,R) != D:\n print("No")\n exit(0)\n \nprint("Yes")\n\n \n \n', 'import sys\nsys.setrecursionlimit(10**5)\nN,M = map(int, input().split())\ninput = sys.stdin.readline\nLRD = [ [int(j) for j in input().split()] for _ in range(M)]\n\ndata = [x for x in range(N+1)]\nrank = [0] * (N+1)\ndiff_weight = [0] * (N+1)\n\ndef root(x):\n if data[x] == x:\n return x\n else:\n r = root( data[x] )\n diff_weight[x] += diff_weight[ data[x] ]\n data[x] = r\n return r\n\ndef weight(x):\n # _ = root(x)\n return diff_weight[x]\n\n\ndef diff(x,y):\n return weight(y) - weight(x)\n\ndef merge(x,y,w):\n w += weight(x); w -= weight(y)\n x = root(x)\n y = root(y)\n if x == y: return False\n if rank[x] < rank[y]: x,y = y,x; w = -w\n if rank[x] == rank[y]: rank[x] += 1\n data[y] = x\n diff_weight[y] = w\n return True\n\ndef issame(x,y):\n return root(x) == root(y)\n\nfor i in range(M):\n L,R,D = LRD[i]\n # print(L,R,D)\n if not issame(L,R):\n _ = merge(L,R,D)\n else:\n if diff(L,R) != D:\n print("No")\n exit(0)\n \nprint("Yes")\n\n \n \n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s768146447', 's856376119', 's000777807']
[705216.0, 5492.0, 46892.0]
[1919.0, 23.0, 787.0]
[982, 1011, 1052]
p03452
u608088992
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['from collections import deque\nN, M = map(int, input().split())\nInf = 10000000000\nEdge = [[] for i in range(N)]\nfor i in range(M):\n l, r, d = map(int, input().split())\n Edge[l-1].append((r-1, d))\n Edge[r-1].append((l-1, -d))\n \nNode = [Inf for i in range(N)]\nPossible = True\nfor i in range(N):\n if not Possible:\n break\n elif Node[i] == Inf:\n Node[i] = 0\n Q = [i]\n while Q:\n now = deque.popleft(Q)\n for e in Edge[now]:\n if Node[e[0]] == Inf:\n Node[e[0]] = Node[now] + e[1]\n Q.append(e[0])\n elif Node[now] + e[1] != Node[e[0]]:\n Possible = False\n break\nprint("Yes" if Possible else "No")', 'from collections import deque\nN, M = map(int, input().split())\nInf = 10000000000\nEdge = [[] for i in range(N)]\nfor i in range(M):\n l, r, d = map(int, input().split())\n Edge[l-1].append((r-1, d))\n Edge[r-1].append((l-1, -d))\n \nNode = [Inf for i in range(N)]\nPossible = True\nfor i in range(N):\n if not Possible:\n break\n elif Node[i] == Inf:\n Node[i] = 0\n Q = deque([i])\n while Q:\n now = Q.popleft()\n for e in Edge[now]:\n if Node[e[0]] == Inf:\n Node[e[0]] = Node[now] + e[1]\n Q.append(e[0])\n elif Node[now] + e[1] != Node[e[0]]:\n Possible = False\n break\nprint("Yes" if Possible else "No")']
['Runtime Error', 'Accepted']
['s150650985', 's567211504']
[63068.0, 66272.0]
[980.0, 1148.0]
[754, 756]
p03452
u620480037
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['import heapq\n\nN,M=map(int,input().split())\n\nC=[0 for i in range(N+1)]\nL=[[]for i in range(N+1)]\nA=[0 for i in range(N+1)]\nB=[]\n\nfor i in range(M):\n l,r,d=map(int,input().split())\n B.append([l,r,d])\n C[r]=1\n L[l].append([l,r,d])\nfor i in range(N+1):\n if C[i]==0:\n A[i]=0\nfor i in range(1,N+1):\n if A[i]==0:\n if len(L[i])>0:\n Q=[]\n for l,r,d in L[i]:\n Q.append([A[i]+d,r,l])\n #print(Q)\n heapq.heapify(Q)\n for j in range(10**6):\n if len(Q)==0:\n break\n else:\n q=Q[0]\n if A[q[1]]>=q[0]:\n A[q[1]]=q[0]\n for k in L[q[1]]:\n heapq.heappush(Q,[q[0]+k[2],k[1],k[0]])\n heapq.heappop(Q)\n#print(C)\n#print(A)\nfor i in range(M):\n\n if A[B[i][1]]!=A[B[i][0]]+B[i][2]:\n print("No")\n exit()\nprint("Yes")', 'import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\nN,M=map(int,input().split())\n\nL=[[]for i in range(N+1)]\nD=dict()\nfor i in range(M):\n l,r,d=map(int,input().split())\n L[l].append([r,d])\n L[r].append([l,-d])\n D[i]=(l,r,d)\n \nC=["N" for i in range(N+1)]\n\ndef dfs(x):\n for i,j in L[x]:\n if C[i]=="N":\n C[i]=C[x]+j\n dfs(i)\n\nfor i in range(1,N+1):\n if C[i]=="N":\n C[i]=0\n dfs(i)\n#print(C)\n#print(D)\nfor i in range(M):\n l,r,d=D[i]\n if C[r]-C[l]!=d:\n print("No")\n exit()\nprint("Yes")']
['Wrong Answer', 'Accepted']
['s882109138', 's261645576']
[135244.0, 162812.0]
[2112.0, 1823.0]
[977, 575]
p03452
u637175065
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,m = LI()\n a = [LI() for _ in range(m)]\n e = collections.defaultdict(list)\n for l,r,d in a:\n e[l-1].append((r-1,d))\n e[r-1].append((l-1,-d))\n\n b = ['s'] * n\n def g(i,c):\n if b[i] != 's' and c != 's':\n return False\n if b[i] != 's':\n if c == 's':\n return True\n return b[i] == c\n if c == 's':\n c = 0\n b[i] = c\n for r,d in e[i]:\n if not g(r,c+d):\n return False\n return True\n\n for i in range(n):\n if not g(i,'s'):\n return 'No'\n return 'Yes'\n\n\nprint(main())\n\n\n\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,m = LI()\n a = [LI() for _ in range(m)]\n e = collections.defaultdict(list)\n for _ in range(m):\n l,r,d = LI()\n e[l-1].append((r-1,d))\n e[r-1].append((l-1,-d))\n\n b = [False] * n\n def g(i,c):\n if b[i] != False:\n if c == False:\n return True\n return b[i] == c\n if c == False:\n c = 0\n b[i] = c\n for r,d in e[i]:\n if not g(r,c+d):\n return False\n return True\n\n for i in range(n):\n if not g(i,False):\n return 'No'\n return 'Yes'\n\n\nprint(main())\n\n\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,m = LI()\n e = [[] for _ in range(n)]\n if m > 0:\n for _ in range(m):\n l,r,d = LI()\n e[l-1].append((r-1,d))\n e[r-1].append((l-1,-d))\n\n b = [None] * n\n\n for i in range(n):\n if not b[i] is None:\n continue\n b[i] = 0\n q = [i]\n qi = 0\n nq = []\n while True:\n if len(q) == qi:\n if not nq:\n break\n q = nq\n qi = 0\n nq = []\n j = q[qi]\n qi += 1\n c = b[j]\n for r,d in e[j]:\n if b[r] is None:\n b[r] = c+d\n nq.append(r)\n else:\n if b[r] != c+d:\n return 'No'\n\n return 'Yes'\n\n\nprint(main())\n\n\n"]
['Wrong Answer', 'Runtime Error', 'Accepted']
['s114757109', 's237905873', 's375959961']
[110600.0, 44032.0, 68468.0]
[1102.0, 468.0, 871.0]
[1227, 1198, 1419]
p03452
u692336506
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['setrecursionlimit(1000000)\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (place[i], place[i])\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n #print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\n\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n \n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print("No")\n exit()\n\nprint("Yes")', 'setrecursionlimit(1000000)\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (place[i], place[i])\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n #print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\n\nprint("Yes")', 'from sys import exit, setrecursionlimit\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict\nfrom bisect import bisect\nsetrecursionlimit(1000000)\n\n\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (i,i)\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n #print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print("No")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n \n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print("No")\n exit()\nprint("Yes")']
['Runtime Error', 'Runtime Error', 'Accepted']
['s039294444', 's897241885', 's517679379']
[3064.0, 3064.0, 134596.0]
[17.0, 17.0, 1794.0]
[852, 858, 992]
p03452
u724687935
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['class WeightedUnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n self.par_weight = [0] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n root = self.find(self.parents[x])\n self.par_weight[x] += self.par_weight[self.parents[x]]\n self.parents[x] = root\n return self.parents[x]\n\n def union(self, x, y, w):\n w = w + self.weight(x) - self.weight(y)\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n self.parents[y] += self.parents[x]\n self.parents[x] = y\n self.par_weight[x] = -w\n else:\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n self.par_weight[y] = w\n\n def weight(self, x):\n if self.parents[x] < 0:\n return 0\n else:\n return self.par_weight[x] + self.weight(self.parents[x])\n\n def diff(self, x, y):\n if self.find(x) != self.find(y):\n raise Exception(\'"{}" belongs to a different tree from "{}"\'.format(x, y))\n return self.find_position(y) - self.find_position(x)\n\n\nN, M = map(int, input().split())\nuf = WeightedUnionFind(N)\nfor i in range(M):\n L, R, D = map(int, input().split())\n L -= 1\n R -= 1\n if uf.find(L) == uf.find(R):\n if uf.diff(L, R) != D:\n res = \'No\'\n break\n else:\n uf.union(L, R, D)\nelse:\n res = \'Yes\'\n\nprint(res)\n', "import sys\nsys.setrecursionlimit(10 ** 6)\n\n\ndef dfs(p):\n for edge in G[p]:\n if X[edge[0]] is not None:\n if X[edge[0]] - X[p] != edge[1]:\n print('No')\n exit()\n else:\n X[edge[0]] = X[p] + edge[1]\n dfs(edge[0])\n\n\nN, M = map(int, input().split())\nG = [[] for _ in range(N)]\n\nfor i in range(M):\n L, R, D = map(int, input().split())\n L -= 1\n R -= 1\n G[L].append((R, D))\n G[R].append((L, -D))\n\nX = [None] * N\nfor i in range(N):\n if X[i] is None:\n X[i] = 0\n dfs(i)\n\nprint('Yes')\n"]
['Runtime Error', 'Accepted']
['s188869427', 's091566613']
[7024.0, 128996.0]
[348.0, 1368.0]
[1547, 583]
p03452
u761320129
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["N,M = map(int,input().split())\nes = [[] for i in range(N)]\nfor i in range(M):\n l,r,d = map(int,input().split())\n l,r = l-1,r-1\n es[l].append((r,d))\n es[r].append((l,-d))\n\nfor i in range(N):\n if dist[i] is not None: continue\n dist = [None] * N\n dist[i] = 0\n stack = [i]\n while stack:\n v = stack.pop()\n for to,d in es[v]:\n if dist[to] is None:\n dist[to] = dist[v] + d\n if not checked[to]:\n stack.append(to)\n else:\n if dist[to] != dist[v] + d:\n print('No')\n exit()\nprint('Yes')\n", "N,M = map(int,input().split())\nes = [[] for i in range(N)]\nfor i in range(M):\n l,r,d = map(int,input().split())\n l,r = l-1,r-1\n es[l].append((r,d))\n es[r].append((l,-d))\n\ndist = [None] * N\nfor i in range(N):\n if dist[i] is not None: continue\n dist[i] = 0\n stack = [i]\n while stack:\n v = stack.pop()\n for to,d in es[v]:\n if dist[to] is None:\n dist[to] = dist[v] + d\n stack.append(to)\n else:\n if dist[to] != dist[v] + d:\n print('No')\n exit()\nprint('Yes')\n"]
['Runtime Error', 'Accepted']
['s336634395', 's861649153']
[61840.0, 65948.0]
[1012.0, 1222.0]
[640, 596]
p03452
u798129018
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['N,M = map(int,input().split())\nAdj_list = defaultdict(set)\n\nfor i in range(M):\n a, b, c = map(int, input().split())\n Adj_list[a-1].add((b-1, c))\n Adj_list[b-1].add((a-1, -c))\nvisited =[None]*(N)\nok = True\nstack = []\nfor x in range(N):\n if visited[x] is not None:continue\n visited[x] = 0\n stack = [x]\n while stack:\n v = stack.pop()\n for to,d in Adj_list[v]:\n if visited[to] is None:\n visited[to] = G[v] + d\n stack.append(to)\n else:\n if G[to] != G[v]+d:\n ok = False\n break\n if ok == False:\n break\nprint("Yes" if ok else "No")', 'N,M = map(int,input().split())\nAdj_list = [[] for _ in range(N) ]\n\nfor i in range(M):\n a, b, c = map(int, input().split())\n Adj_list[a-1].add((b-1, c))\n Adj_list[b-1].add((a-1, -c))\nvisited =[None]*(N)\nok = True\nstack = []\nfor x in range(N):\n if visited[x] is not None:continue\n visited[x] = 0\n stack = [x]\n while stack:\n v = stack.pop()\n for to,d in Adj_list[v]:\n if visited[to] is None:\n visited[to] = G[v] + d\n stack.append(to)\n else:\n if G[to] != G[v]+d:\n ok = False\n break\n if ok == False:\n break\nprint("Yes" if ok else "No")', 'import itertools\nimport math\nfrom collections import deque\nfrom collections import defaultdict\nfrom itertools import permutations\nimport heapq\nimport bisect\nfrom scipy.sparse.csgraph import floyd_warshall as wf\nINF = float("inf")\n\n\nN,M = map(int,input().split())\nAdj_list = defaultdict(set)\n\nfor i in range(M):\n a, b, c = map(int, input().split())\n Adj_list[a-1].add((b-1, c))\n Adj_list[b-1].add((a-1, -c))\nvisited =[None]*(N)\nok = True\nstack = []\nfor x in range(N):\n if visited[x] is not None:continue\n visited[x] = 0\n stack = [x]\n while stack:\n v = stack.pop()\n for to,d in Adj_list[v]:\n if visited[to] is None:\n visited[to] = G[v] + d\n stack.append(to)\n else:\n if G[to] != G[v]+d:\n ok = False\n break\n if ok == False:\n break\nprint("Yes" if ok else "No")\n', 'import itertools\nimport math\nfrom collections import deque\nfrom collections import defaultdict\nfrom itertools import permutations\nimport heapq\nimport bisect\nfrom scipy.sparse.csgraph import floyd_warshall as wf\nINF = float("inf")\n\n\nN,M = map(int,input().split())\nAdj_list = defaultdict(set)\n\nfor i in range(M):\n a, b, c = map(int, input().split())\n Adj_list[a-1].add((b-1, c))\n Adj_list[b-1].add((a-1, -c))\nvisited =[None]*(N)\nok = True\nstack = []\nfor x in range(N):\n if visited[x] is not None:continue\n visited[x] = 0\n stack = [x]\n while stack:\n v = stack.pop()\n for to,d in Adj_list[v]:\n if visited[to] is None:\n visited[to] = visited[v] + d\n stack.append(to)\n else:\n if visited[to] != visited[v]+d:\n ok = False\n break\n if ok == False:\n break\nprint("Yes" if ok else "No")']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s213673593', 's431183907', 's476145199', 's129184494']
[3064.0, 11032.0, 103248.0, 111744.0]
[17.0, 87.0, 1438.0, 1915.0]
[659, 666, 892, 909]
p03452
u808427016
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['class UnionFind:\n def __init__(self, size):\n self.table = [[-1, 0] for _ in range(size + 1)]\n\n def find(self, x):\n n, d = self.table[x] \n if n < 0:\n return [x, d]\n else:\n n1, d1 = self.find(n)\n r = [n1, d1 + d]\n self.table[x] = r\n return r\n\n \n def union(self, x, y, d):\n n1, d1 = self.find(x)\n n2, d2 = self.find(y)\n if n1 != n2:\n if self.table[n1][0] <= self.table[n2][0]:\n \n self.table[n2] = [n1, d1+d]\n else:\n self.table[n2][0] -= 1\n self.table[n1] = [n2, d2-d]\n else:\n print(d1, d2, d)\n if d2 - d1 != d:\n return False\n return True\n\ndef solve(N, M, lrd):\n uf = UnionFind(N)\n for l, r, d in lrd:\n if not uf.union(l, r, d):\n return False\n return True\n\nif __name__ == "__main__":\n N, M = [int(x) for x in input().split()]\n lrd = []\n for i in range(M):\n lrd.append([int(x) for x in input().split()])\n if solve(N, M, lrd):\n print("Yes")\n else:\n print("No")\n', 'import sys\n\nsys.setrecursionlimit(100000)\n\nclass UnionFind:\n def __init__(self, size):\n self.table = [[-1, 0] for _ in range(size + 1)]\n\n def find(self, x):\n n, d = self.table[x] \n if n < 0:\n return [x, d]\n else:\n n1, d1 = self.find(n)\n r = [n1, d1 + d]\n self.table[x] = r\n return r\n\n \n def union(self, x, y, d):\n n1, d1 = self.find(x)\n n2, d2 = self.find(y)\n if n1 != n2:\n if self.table[n1][0] <= self.table[n2][0]:\n \n self.table[n1][0] -= 1\n self.table[n2] = [n1, d1+d]\n else:\n self.table[n2][0] -= 1\n self.table[n1] = [n2, d2-d]\n else:\n print(d1, d2, d)\n if d2 - d1 != d:\n return False\n return True\n\ndef solve(N, M, lrd):\n uf = UnionFind(N)\n for l, r, d in lrd:\n if not uf.union(l, r, d):\n return False\n return True\n\nif __name__ == "__main__":\n N, M = [int(x) for x in input().split()]\n lrd = []\n for i in range(M):\n lrd.append([int(x) for x in input().split()])\n if solve(N, M, lrd):\n print("Yes")\n else:\n print("No")\n', 'from collections import defaultdict\n\nclass XUnionFind(object):\n\n def __init__(self):\n self.table = defaultdict(lambda:-1)\n self.dtable = defaultdict(lambda:0)\n\n def find(self, x):\n parent = self.table[x] \n if parent < 0:\n return x, 0\n else:\n root, distance = self.find(parent)\n new_distance = distance + self.dtable[x]\n self.table[x] = root\n self.dtable[x] = new_distance\n return root, new_distance\n\n def union(self, x1, x2, d = 0):\n root1, distance1 = self.find(x1)\n root2, distance2 = self.find(x2)\n if root1 == root2:\n if distance2 - distance1 != d:\n return False\n return True\n if root1 < root2:\n self.table[root1] += self.table[root2]\n self.table[root2] = root1\n self.dtable[root2] = distance1 + d - distance2\n else:\n self.table[root2] += self.table[root1]\n self.table[root1] = root2\n self.dtable[root1] = distance2 - d - distance1\n return True\n\ndef solve(N, M, lrd):\n uf = XUnionFind()\n for l, r, d in lrd:\n rc = uf.union(l, r, d)\n if rc == False:\n return False\n return True\n \n\nif __name__ == "__main__":\n N, M = [int(x) for x in input().split()]\n lrd = []\n for i in range(M):\n lrd.append([int(x) for x in input().split()])\n if solve(N, M, lrd):\n print("Yes")\n else:\n print("No")\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s019421294', 's994470332', 's824643096']
[52924.0, 52912.0, 59772.0]
[878.0, 832.0, 1147.0]
[1210, 1292, 1517]
p03452
u835482198
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['from collections import defaultdict\n\n\nn, m = list(map(int, input().split()))\n\ng = [[] for _ in range(n + 1)]\nfor _ in range(m):\n l, r, d = map(int, input().split())\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nds = [None for _ in range(n + 1)]\n\n\ndef check(v):\n for next_v, d in g[v]:\n if ds[next_v] is None:\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(1, n + 1):\n if ds[v] is None:\n ds[v] = 0\n if check(v):\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n', 'from collections import defaultdict\n\n\nn, m = list(map(int, input().split()))\n\ng = defaultdict(list)\nfor _ in range(m):\n l, r, d = map(int, input().split())\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nchecked = {}\nds = defaultdict(int)\n\n\ndef check(v):\n for next_v, d in g[v]:\n if not (next_v in ds):\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(1, n + 1):\n if (not (v in ds)):\n ds[v] = 0\n if check(v):\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n', 'import sys\n\nsys.setrecursionlimit(200002)\n\nn, m = list(map(int, input().split()))\n\ng = [[] for _ in range(n)]\nfor _ in range(m):\n l, r, d = map(int, input().split())\n l -= 1\n r -= 1\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nds = [None for _ in range(n + 1)]\n\n\ndef check(v):\n for next_v, d in g[v]:\n if ds[next_v] is None:\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(n):\n if ds[v] is None:\n ds[v] = 0\n if check(v):\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n', 'from collections import defaultdict\n\n\nn, m = list(map(int, input().split()))\n\ng = defaultdict(list)\nfor _ in range(m):\n l, r, d = map(int, input().split())\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nchecked = {}\nds = defaultdict(int)\n\n\ndef check(v):\n if (not (v in ds)):\n ds[v] = 0\n for next_v, d in g[v]:\n if not (next_v in ds):\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(1, n + 1):\n if check(v):\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n', 'from collections import defaultdict\n\n\nn, m = list(map(int, input().split()))\n\ng = defaultdict(list)\nfor _ in range(m):\n l, r, d = map(int, input().split())\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nchecked = {}\nds = [None for _ in range(n + 1)]\n\n\ndef check(v):\n for next_v, d in g[v]:\n if ds[next_v] is None:\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(1, n + 1):\n if ds[v] is None:\n ds[v] = 0\n if check(v):\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n', 'import sys\n\nsys.setrecursionlimit(200002)\n\nn, m = list(map(int, input().split()))\n\ng = [[] for _ in range(n)]\nfor _ in range(m):\n l, r, d = map(int, input().split())\n l -= 1\n r -= 1\n g[l].append((r, d))\n g[r].append((l, -d))\n\n\nds = [None for _ in range(n + 1)]\n\n\ndef check(v):\n for next_v, d in g[v]:\n if ds[next_v] is None:\n ds[next_v] = ds[v] + d\n if check(next_v) is False:\n return False\n elif not (ds[next_v] - ds[v] == d):\n return False\n return True\n\n\nvalid = True\nfor v in range(n):\n if ds[v] is None:\n ds[v] = 0\n if check(v) is False:\n valid = False\n break\n\nif valid:\n print("Yes")\nelse:\n print("No")\n']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s185194788', 's556976442', 's651722524', 's665794112', 's883211770', 's666252841']
[64008.0, 68576.0, 129032.0, 68580.0, 69288.0, 129032.0]
[1029.0, 1120.0, 1340.0, 1110.0, 1164.0, 1531.0]
[699, 693, 715, 693, 703, 724]
p03452
u844646164
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
['class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n self.root[x] = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n return self.root[x]\n\n def GetWeight(self, x):\n self.Find_Root(self, x)\n return self.weight[x]\n\n def Unite(self, x, y, w):\n w += self.GetWeight(x)\n w -= self.GetWeight(y)\n x = self.Find_Root(x)\n y = self.Find_Root(y)\n if(x == y):\n return False\n\n if self.rnk[x] < self.rnk[y]:\n x, y = y, x\n w = -w\n if self.rnk[x] == self.rnk[y]:\n self.rnk[x] += 1\n \n self.root[y] = x\n self.weight[y] = w\n\n return True\n \n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n \n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n \n def Diff(self, x, y):\n if self.isSameGroup(x, y):\n return abs(self.GetWeight(y)- self.GetWeight(xs))\n else:\n return None\n\ndef main():\n N, M = map(int, input().split())\n lrd = [list(map(int, input().split())) for _ in range(M)]\n U = UnionFind(N)\n flag = True\n\n for i in range(M):\n l, r, d = lrd[i]\n U.Unite(l, r, d)\n for i in range(M):\n l, r, d = lrd[i]\n if U.isSameGroup(l, r):\n if U.Diff(l, r) != d:\n print(\'No\')\n exit()\n print(\'Yes\')\n \n \nif __name__ == "__main__":\n main()', 'class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n self.root[x] = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n return self.root[x]\n\n def Unite(self, x, y, w):\n rx = self.Find_Root(x)\n ry = self.Find_Root(y)\n \n if(rx == ry):\n return self.Diff(x, y) == w\n elif(self.rnk[rx] > self.rnk[ry]):\n self.root[ry] = rx\n self.weight[ry] = w - self.weight[y] + self.weight[x]\n else:\n self.root[rx] = ry\n self.weight[rx] = -w - self.weight[x] + self.weight[y]\n if(self.rnk[rx] == self.rnk[ry]):\n self.rnk[ry] += 1\n \n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n \n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n \n def Diff(self, x, y):\n return self.weight[y] - self.weight[x]\n\ndef main():\n N, M = map(int, input().split())\n lrd = [list(map(int, input().split())) for _ in range(M)]\n U = UnionFind(N)\n flag = True\n for i in range(M):\n l, r, d = lrd[i]\n flag = U.Unite(l, r, d)\n if not flag:\n print(\'No\')\n exit()\n print(\'Yes\')\n \n \nif __name__ == "__main__":\n main()', 'class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n self.root[x] = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n return self.root[x]\n\n def Unite(self, x, y, w):\n rx = self.Find_Root(x)\n ry = self.Find_Root(y)\n \n if(rx == ry):\n return self.Diff(x, y) == w\n elif(self.rnk[rx] > self.rnk[ry]):\n self.root[ry] = rx\n self.weight[ry] = -w - self.weight[y] + self.weight[x]\n else:\n self.root[rx] = ry\n self.weight[rx] = w - self.weight[x] + self.weight[y]\n if(self.rnk[rx] == self.rnk[ry]):\n self.rnk[ry] += 1\n \n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n \n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n \n def Diff(self, x, y):\n if self.isSameGroup(x, y):\n return self.weight[y] - self.weight[x]\n else:\n return None\n\ndef main():\n N, M = map(int, input().split())\n lrd = [list(map(int, input().split())) for _ in range(M)]\n U = UnionFind(N)\n flag = True\n\n for i in range(M):\n l, r, d = lrd[i]\n flag = U.Unite(l-1, r-1, d)\n if not flag:\n print(\'No\')\n exit()\n print(\'Yes\')\n\n \n \nif __name__ == "__main__":\n main()', 'class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n self.root[x] = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n return self.root[x]\n\n def Unite(self, x, y, w):\n rx = self.Find_Root(x)\n ry = self.Find_Root(y)\n print(rx, ry)\n \n if(rx == ry):\n return \n elif(self.rnk[rx] > self.rnk[ry]):\n self.root[ry] = rx\n self.weight[ry] = w - self.weight[y] + self.weight[x]\n else:\n self.root[rx] = ry\n self.weight[rx] = -w - self.weight[x] + self.weight[y]\n if(self.rnk[rx] == self.rnk[ry]):\n self.rnk[ry] += 1\n \n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n \n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n \n def Diff(self, x, y):\n return self.weight[y] - self.weight[x]\n\ndef main():\n N, M = map(int, input().split())\n lrd = [list(map(int, input().split())) for _ in range(M)]\n U = UnionFind(N)\n for i in range(M):\n l, r, d = lrd[i]\n U.Unite(l, r, d)\n for i in range(M):\n l, r, d = lrd[i]\n if U.Diff(l, r) != d:\n print(\'No\')\n exit()\n print(\'Yes\')\n \nif __name__ == "__main__":\n main()', 'class UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n \n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n self.root[x] = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n return self.root[x]\n\n def Unite(self, x, y, w):\n rx = self.Find_Root(x)\n ry = self.Find_Root(y)\n print(rx, ry)\n \n if(rx == ry):\n return self.Diff(x, y) == w\n elif(self.rnk[rx] > self.rnk[ry]):\n self.root[ry] = rx\n self.weight[ry] = w - self.weight[y] + self.weight[x]\n else:\n self.root[rx] = ry\n self.weight[rx] = -w - self.weight[x] + self.weight[y]\n if(self.rnk[rx] == self.rnk[ry]):\n self.rnk[ry] += 1\n \n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n \n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n \n def Diff(self, x, y):\n return self.weight[y] - self.weight[x]\n\ndef main():\n N, M = map(int, input().split())\n lrd = [list(map(int, input().split())) for _ in range(M)]\n U = UnionFind(N)\n flag = True\n for i in range(M):\n l, r, d = lrd[i]\n flag = U.Unite(l, r, d)\n if not flag:\n print(\'No\')\n exit()\n print(\'Yes\')\n \n \nif __name__ == "__main__":\n main()', "import sys\nsys.setrecursionlimit(10**5)\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1]*(n+1)\n self.rnk = [0]*(n+1)\n self.weight = [0]*(n+1)\n def Find_Root(self, x):\n if(self.root[x] < 0):\n return x\n else:\n r = self.Find_Root(self.root[x])\n self.weight[x] += self.weight[self.root[x]]\n self.root[x] = r\n return r\n def GetWeight(self, x):\n self.Find_Root(x)\n return self.weight[x]\n def Unite(self, x, y, w):\n w += self.GetWeight(x)\n w -= self.GetWeight(y)\n x = self.Find_Root(x)\n y = self.Find_Root(y)\n if(x == y):\n return False\n if self.rnk[x] < self.rnk[y]:\n x, y = y, x\n w = -w\n if self.rnk[x] == self.rnk[y]:\n self.rnk[x] += 1\n self.root[y] = x\n self.weight[y] = w\n return True\n def isSameGroup(self, x, y):\n return self.Find_Root(x) == self.Find_Root(y)\n def Count(self, x):\n return -self.root[self.Find_Root(x)]\n def Diff(self, x, y):\n return self.GetWeight(y) - self.GetWeight(x)\n\nn, m = map(int, input().split())\nlrd = [list(map(int, input().split())) for _ in range(m)]\nuf = UnionFind(n+1)\nfor l, r, d in lrd:\n if not uf.isSameGroup(l, r):\n uf.Unite(l, r, d)\n else:\n if uf.Diff(l, r) != d:\n print('No')\n exit()\n\nprint('Yes')\n"]
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s191413955', 's573770969', 's595342879', 's782156044', 's811760075', 's136939657']
[55148.0, 55144.0, 55132.0, 61728.0, 55144.0, 58000.0]
[686.0, 658.0, 690.0, 1342.0, 677.0, 1522.0]
[1623, 1438, 1511, 1467, 1460, 1291]
p03452
u875291233
2,000
262,144
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds. It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
["class UnionFind:\n def __init__(self, size):\n self.parent = [-1 for i in range(size)]\n self.diff_potential = [0 for i in range(size)]\n\n def root(self, x): \n if self.parent[x] < 0:\n return x\n else:\n rx = self.root(self.parent[x]) \n self.diff_potential[x] += self.diff_potential[self.parent[x]] \n self.parent[x] = rx \n return rx\n\n def merge(self, x, y, diffxy): \n diffxy = self.diff_potential[x] + diffxy - self.diff_potential[y] \n x = self.root(x) \n y = self.root(y) \n if x == y:\n return False\n if self.parent[x] > self.parent[y]: \n x,y=y,x\n diffxy = -diffxy\n self.parent[x] += self.parent[y] \n self.parent[y] = x \n self.diff_potential[y] = diffxy \n return True\n\n def issame(self, x, y): \n return self.root(x) == self.root(y)\n \n def diff(self,x,y): \n if self.root(x) == self.root(y): \n return self.diff_potential[y] - self.diff_potential[x]\n else:\n return None\n\n def size(self,x): \n return -self.parent[self.root(x)]\n#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nn,m = list(map(int,input().split()))\n\nuf = UnionFind(n)\nans = True\nfor i in range(m):\n l,r,d=list(map(int,input().split()))\n if uf.issame(l,r):\n ans = d==uf.diff(l,r)\n else:\n uf.merge(l,r,d)\n if ans == False:\n break\n\nif ans == False:\n print('No')\nelse:\n print('Yes')\n\n\n\n\n", "class PotUnionFind:\n def __init__(self, size):\n self.parent = [-1 for i in range(size)]\n self.diff_p = [0 for i in range(size)]\n\n def root(self, x): \n if self.parent[x] < 0:\n return x\n else:\n rx = self.root(self.parent[x]) \n self.diff_p[x] += self.diff_p[self.parent[x]] \n self.parent[x] = rx \n return rx\n\n def merge(self, x, y, dxy): \n dxy = self.diff_p[x] + dxy - self.diff_p[y] \n x = self.root(x) \n y = self.root(y) \n if x == y:\n return False\n if self.parent[x] > self.parent[y]: \n x,y=y,x\n dxy = -dxy\n self.parent[x] += self.parent[y] \n self.parent[y] = x \n self.diff_p[y] = dxy \n return True\n\n def issame(self, x, y): \n return self.root(x) == self.root(y)\n \n def diff(self,x,y): \n if self.root(x) == self.root(y): \n return self.diff_p[y] - self.diff_p[x]\n else:\n return None\n\n def size(self,x): \n return -self.parent[self.root(x)]\n#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nn,m = list(map(int,input().split()))\n\nuf = PotUnionFind(n)\nans = True\nfor i in range(m):\n l,r,d=list(map(int,input().split()))\n l-=1;r-=1;\n if uf.issame(l,r):\n ans = d==uf.diff(l,r)\n else:\n uf.merge(l,r,d)\n if ans == False:\n break\n\nif ans == False:\n print('No')\nelse:\n print('Yes')\n\n\n\n\n"]
['Runtime Error', 'Accepted']
['s110640844', 's896011511']
[9008.0, 10796.0]
[690.0, 1495.0]
[2477, 2397]
p03459
u090406054
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
["n=int(input())\ntxy=[input().split() for i in range(n)]\nif n!=1:\n for i in range(n-1):\n subX=int(txy[i+1][1])-int(txy[i][1])\n subY=int(txy[i+1][2])-int(txy[i][2])\n subT=int(txy[i+1][0])-int(txy[i][0])\n t=[]\n p=subT-subX-subY\n t.append(p)\n s=[]\n for i in range(len(t)):\n if t[i]<0 or t[i]%2==1:\n s.append(t[i])\n if s==[]:\n print('Yes')\n else:\n print('No')\n \nelse:\n subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])\n if subby>=0 and subby%2==0:\n print('Yes')\n else:\n print('No')\n", "n=int(input())\ntxy=[input().split() for i in range(n)]\nif n!=1:\n for i in range(n-1):\n subX=abs(int(txy[i+1][1])-int(txy[i][1]))\n subY=abs(int(txy[i+1][2])-int(txy[i][2]))\n subT=int(txy[i+1][0])-int(txy[i][0])\n t=[]\n p=subT-subX-subY\n t.append(p)\n for i in range(len(t)):\n if t[i]<0 or t[i]%2==1:\n print('No')\n else:\n print('Yes')\nelse:\n subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])\n if subby>=0 and subby%2==0:\n print('Yes')\n else:\n print('No')"]
['Wrong Answer', 'Accepted']
['s624923359', 's452251087']
[32148.0, 32148.0]
[428.0, 411.0]
[558, 504]
p03459
u536113865
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
["import sys\nn = int(input())\npt, px, py = 0, 0, 0\nfor _ in range(n):\n t, x, y = map(int,input().split())\n dt = abs(t-pt)\n dx = abs(x-px)\n dy = abs(y-py)\n if dt<dx+dy or dt%2!=(dx+dy)%2:\n print('No')\n sys.exit() \n pt,px,py = t,x,y\nprint('Yes'", "import sys\nn = int(input())\npt, px, py = 0, 0, 0\nfor _ in range(n):\n t, x, y = map(int,input().split())\n dt = abs(t-pt)\n dx = abs(x-px)\n dy = abs(y-py)\n if dt<dx+dy or dt%2!=(dx+dy)%2:\n print('No')\n sys.exit() \n pt,px,py = t,x,y\nprint('Yes')"]
['Runtime Error', 'Accepted']
['s156241971', 's700935416']
[3064.0, 3064.0]
[17.0, 389.0]
[275, 276]
p03459
u536659057
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
["from collections import deque\n\nnum = int(input())\n\nto_num = lambda x : [int(i) for i in input().split(' ')]\n\nmasume = {}\nfor i in range(num):\n line = to_num(1)\n for l in range(len(line)):\n masume[line[0]] = (line[1], line[2])\n\nmasume_deque = deque(list(masume.keys()))\npre_pos = (0, 0)\npre_times = 0\nfor index in range(num):\n k = masume_deque[index]\n cur_pos = masume[k]\n distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])\n times = abs(k - pre_times)\n if distance % 2 != times % 2 or distance > times:\n ans = False\n break\n else:\n ans = True\n pre_pos = cur_pos\n pre_times = masume_deque[i]\n \nif ans:\n print('Yes')\nelse:\n print('No')\n ", "from collections import deque\n\nnum = int(input())\n\nto_num = lambda x : [int(i) for i in input().split(' ')]\n\nmasume = {}\nfor i in range(num):\n line = to_num(1)\n for l in range(len(line)):\n masume[line[0]] = (line[1], line[2])\n\nmasume_deque = deque(list(masume.keys()))\npre_pos = (0, 0)\npre_times = 0\nfor index in range(num):\n cur_times = masume_deque[index]\n cur_pos = masume[cur_times]\n distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])\n times = abs(cur_times - pre_times)\n if distance % 2 != times % 2 or distance > times:\n ans = False\n break\n else:\n ans = True\n pre_pos = cur_pos\n pre_times = cur_times\n \nif ans:\n print('Yes')\nelse:\n print('No')\n "]
['Wrong Answer', 'Accepted']
['s544454117', 's987235065']
[23760.0, 23760.0]
[484.0, 788.0]
[717, 735]
p03459
u619819312
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
['n=int(input())\ns=[list(map(int,input().split()))for i in range(n)]\ns.insert(0,[0,0,0])\np=0\nfor i in range(n):\n c=s[i+1][0]-s[i][0]\n d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])\n if c<=d or (c-d)%2==1:\n p=1\n break\nprint("No" if p==1 else "Yes")', 'n=int(input())\ns=[list(map(int,input().split()))for i in range(n)]\ns.insert(0,[0,0,0])\np=0\nfor i in range(n):\n c=s[i+1][0]-s[i][0]\n d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])\n if c<d or (c-d)%2==1:\n p=1\n break\nprint("No" if p==1 else "Yes")']
['Wrong Answer', 'Accepted']
['s565970114', 's216083174']
[27300.0, 27300.0]
[348.0, 415.0]
[269, 268]
p03459
u677421794
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
["# -*- coding: utf-8 -*-\nfrom collections import Counter\nimport numpy as np\n\nn, k = list(map(int,input().split()))\ntable = np.zeros((2*k,2*k),dtype='int32')\nfor i in range(n):\n t = input().split()\n if(t[2]=='B'):\n table[int(t[0])%(2*k)][int(t[1])%(2*k)] += 1\n else:\n table[(int(t[0])+k)%(2*k)][int(t[1])%(2*k)] += 1\n \nn_table = np.zeros((3*k,3*k),dtype='int32')\nn_table[0:2*k,0:2*k] = table\nn_table[2*k:3*k,0:2*k] = table[0:k,0:2*k]\nn_table[0:2*k,2*k:3*k] = table[0:2*k,0:k]\nn_table[2*k:3*k,2*k:3*k] = table[0:k,0:k]\n\ni_table = np.zeros((3*k,3*k),dtype='int32')\n\nfor i in range(0,3*k):\n i_table[i][0] = n_table[i][0]\n for j in range(1,3*k):\n i_table[i][j] += i_table[i][j-1] + n_table[i][j] \nfor i in range(1,3*k):\n for j in range(0,3*k):\n i_table[i][j] += i_table[i-1][j] \n\nans = 0\nhope1 = i_table[k-1][k-1]\nhope2 = i_table[2*k-1][2*k-1] - i_table[2*k-1][k-1] - i_table[k-1][2*k-1] + i_table[k-1][k-1]\nans = max(ans,hope1+hope2)\nfor i in range(1,k):\n hope1 = i_table[k-1][i+k-1] - i_table[k-1][i-1]\n hope2 = i_table[2*k-1][i+2*k-1] - i_table[2*k-1][i+k-1] - i_table[k-1][i+2*k-1] + i_table[k-1][i+k-1]\n ans = max(ans,hope1+hope2)\nfor i in range(1,k): \n hope1 = i_table[i+k-1][k-1]- i_table[i-1][k-1]\n hope2 = i_table[i+2*k-1][2*k-1] - i_table[i+2*k-1][k-1] - i_table[i+k-1][2*k-1] + i_table[i+k-1][k-1]\n ans = max(ans,hope1+hope2)\n\nfor i in range(1,k):\n for j in range(1,k): \n hope1 = i_table[i+k-1][j+k-1] - i_table[i+k-1][j-1] - i_table[i-1][j+k-1] + i_table[i-1][j-1]\n hope2 = i_table[i+2*k-1][j+2*k-1] - i_table[i+2*k-1][j+k-1] - i_table[i+k-1][j+2*k-1] + i_table[i+k-1][j+k-1]\n ans = max(ans,hope1+hope2)\nprint(ans)", "# -*- coding: utf-8 -*- \nimport sys\n\nn = int(input())\ntprev = 0\ntdiff = 0\npos = [0, 0]\nfor i in range(n):\n t, x, y = list(map(int,input().split()))\n tdiff = t - tprev\n print(pos,tdiff,abs(x-pos[0])+abs(y-pos[1]))\n if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):\n if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):\n tprev = t\n pos = [x, y]\n else:\n print('No')\n sys.exit()\n else:\n print('No')\n sys.exit()\nelse:\n print('Yes')\n ", "# -*- coding: utf-8 -*- \nimport sys\n\nn = int(input())\ntprev = 0\ntdiff = 0\npos = [0, 0]\nfor i in range(n):\n t, x, y = list(map(int,input().split()))\n tdiff = t - tprev\n if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):\n if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):\n tprev = t\n pos = [x, y]\n else:\n print('No')\n sys.exit()\n else:\n print('No')\n sys.exit()\nelse:\n print('Yes')\n "]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s110603216', 's738165749', 's062264532']
[12472.0, 4596.0, 3064.0]
[149.0, 1203.0, 440.0]
[1742, 517, 468]
p03459
u712429027
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
['import sys\ninput = sys.stdin.readline\nins = lambda: input().rstrip()\nini = lambda: int(input().rstrip())\ninm = lambda: map(int, input().split())\ninl = lambda: list(map(int, input().split()))\nout = lambda x: print(\'\\n\'.join(map(str, x)))\n\nn = ini()\nans = True\nprevt = 0\nprevx = 0\nprevy = 0\nfor _ in range(n):\n t, x, y = inm()\n totalt = t - prevt\n totald = abs(x - prevx) + abs(y - prevy)\n if totald > totalt or (totald % 2) != (totalt % 2):\n ans = False\n break\n prevt = t\n prevx = x\n prevy = y\nprint("YES" if ans else "NO")', 'import sys\ninput = sys.stdin.readline\nins = lambda: input().rstrip()\nini = lambda: int(input().rstrip())\ninm = lambda: map(int, input().split())\ninl = lambda: list(map(int, input().split()))\nout = lambda x: print(\'\\n\'.join(map(str, x)))\n \nn = ini()\nans = True\nprevt = 0\nprevx = 0\nprevy = 0\nfor _ in range(n):\n t, x, y = inm()\n if (abs(x - prevx) + abs(y - prevy)) > (t - prevt) or (t - prevt) % 2 != (abs(x - prevx) + abs(y - prevy)) % 2:\n ans = False\n break\n prevt = t\n prevx = x\n prevy = y\nprint("Yes" if ans else "No")']
['Wrong Answer', 'Accepted']
['s493966468', 's937933232']
[9140.0, 9076.0]
[138.0, 151.0]
[557, 550]
p03459
u729417323
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
["# --*-coding:utf-8-*--\n\n\ndef f(poss):\n lastPos = (0, 0, 0)\n\n for pos in poss:\n t = pos[0] - lastPos[0]\n d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])\n lastPos = pos\n\n if t < d or (t-d)%2 != 0:\n return False\n\n return True\n\n\n\ndef main():\n n = int(input())\n poss = [tuple(map(int, input().split())) for i in range(n)]\n\n print('YES' if f(poss) else 'NO')\n\n\nif __name__ == '__main__':\n main()\n", "# --*-coding:utf-8-*--\n\n\ndef f(poss):\n lastPos = (0, 0, 0)\n\n for pos in poss:\n t = pos[0] - lastPos[0]\n d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])\n\n if t < d or (t-d)%2 != 0:\n return False\n\n return True\n\n\n\ndef main():\n n = int(input())\n poss = [tuple(map(int, input().split())) for i in range(n)]\n\n print('YES' if f(poss) else 'NO')\n\n\nif __name__ == '__main__':\n main()\n", "# --*-coding:utf-8-*--\n\n\ndef f(poss):\n lastPos = (0, 0, 0)\n\n for pos in poss:\n t = pos[0] - lastPos[0]\n d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])\n lastPos = pos\n\n if t < d or (t-d)%2 != 0:\n return False\n\n return True\n\n\n\ndef main():\n n = int(input())\n poss = [tuple(map(int, input().split())) for i in range(n)]\n\n print('Yes' if f(poss) else 'No')\n\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s199658517', 's545854158', 's000684882']
[17312.0, 17308.0, 17324.0]
[341.0, 364.0, 357.0]
[459, 437, 459]
p03459
u785205215
2,000
262,144
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
['import math\nimport itertools\nimport heapq\nfrom sys import stdin, stdout, setrecursionlimit\nfrom bisect import bisect, bisect_left, bisect_right\nfrom collections import defaultdict, deque\n\n\n\n\n# inf = float("inf")\n\n\n\ndef LM(t, r): return list(map(t, r))\ndef R(): return stdin.readline()\ndef RS(): return R().split()\ndef I(): return int(R())\ndef F(): return float(R())\ndef LI(): return LM(int,RS())\ndef LF(): return LM(float,RS())\ndef ONE_SL(): return list(input())\ndef ONE_IL(): return LM(int, ONE_SL())\ndef ALL_IL(): return LM(int,stdin)\n\n##### tools #####\ndef ap(f): return f.append\ndef pll(li): print(\'\\n\'.join(LM(str,li)))\ndef pljoin(li, s): print(s.join(li))\n\n\n\n##### main #####\n\ndef main():\n\tcx = 0; cy = 0\n\tprev_t = 0\n\n\tfor i in range(I()):\n\t\tt, dist_x, dist_y = LI()\n\n\t\tdiff = abs(dist_x - cx) + abs(dist_y - cy)\t\t\n\t\tt -= prev_t\n\n\n\t\tif t > diff and (t - diff)%2 == 0:\n\t\t\tf = True\n\t\telse:\n\t\t\tf = False\n\t\t\tbreak\n\n\t\tprev_t = t\n\t\tcx = dist_x\n\t\tcy = dist_y\n\t\n\tif f:\n\t\tprint("Yes")\n\telse:\n\t\tprint("No")\n\nif __name__ == \'__main__\':\n\tmain()', 'import math\nimport itertools\nimport heapq\nfrom sys import stdin, stdout, setrecursionlimit\nfrom bisect import bisect, bisect_left, bisect_right\nfrom collections import defaultdict, deque\n\n\n\n\n# inf = float("inf")\n\n\n\ndef LM(t, r): return list(map(t, r))\ndef R(): return stdin.readline()\ndef RS(): return R().split()\ndef I(): return int(R())\ndef F(): return float(R())\ndef LI(): return LM(int,RS())\ndef LF(): return LM(float,RS())\ndef ONE_SL(): return list(input())\ndef ONE_IL(): return LM(int, ONE_SL())\ndef ALL_IL(): return LM(int,stdin)\n\n##### tools #####\ndef ap(f): return f.append\ndef pll(li): print(\'\\n\'.join(LM(str,li)))\ndef pljoin(li, s): print(s.join(li))\n\n\n\n##### main #####\n\ndef main():\n\tcx = 0; cy = 0\n\tprev_t = 0\n\n\tfor i in range(I()):\n\t\tt, dist_x, dist_y = LI()\n\n\t\tdiff = abs(dist_x - cx) + abs(dist_y - cy)\t\t\n\t\tspend_time = t - prev_t\n\n\n\t\tif spend_time >= diff and (spend_time - diff)%2 == 0:\n\t\t\tf = True\n\t\telse:\n\t\t\tf = False\n\t\t\tbreak\n\n\t\tprev_t = t\n\t\tcx = dist_x\n\t\tcy = dist_y\n\t\n\tif f:\n\t\tprint("Yes")\n\telse:\n\t\tprint("No")\n\nif __name__ == \'__main__\':\n\tmain()']
['Wrong Answer', 'Accepted']
['s946568097', 's199937706']
[3444.0, 3700.0]
[26.0, 239.0]
[1108, 1139]
p03463
u003501233
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['n,a,b=map(int,input().split())\n\nif (a-b) % 2 == 0:\n print("Aliice")\nelse:\n print("Borys")', 'n,a,b=map(int,input().split())\n\nif (a-b) % 2 == 0:\n print("Alice")\nelse:\n print("Borys")']
['Wrong Answer', 'Accepted']
['s671367870', 's822685992']
[2940.0, 2940.0]
[17.0, 18.0]
[91, 90]
p03463
u010090035
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['n,a,b=map(int,input().split())\nif(b-a %2==0):\n print("Alice")\nelse:\n print("Borys")', 'n,a,b=map(int,input().split())\nif((b-a) %2==0):\n print("Alice")\nelse:\n print("Borys")']
['Wrong Answer', 'Accepted']
['s006478268', 's594523249']
[2940.0, 3064.0]
[18.0, 17.0]
[89, 91]
p03463
u020798319
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['n , a , b = map(int,input().split())\nif (n - b) % 2 == 0 and n-b >= 0 or a+b != n or n+a == b:\n print("Borys")\nelse :\n print("Alice")', 'n , a , b = map(int,input().split())\nif (a- b) % 2 == 0 :\n print("Alice")\nelse:\n print("Borys")']
['Wrong Answer', 'Accepted']
['s846222849', 's306394494']
[8992.0, 9000.0]
[28.0, 30.0]
[135, 97]
p03463
u021916304
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
["def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nn,a,b = iim()\n\nif (b-a)%2 == 1:\n if a == 1:\n print('Borys')\n else:\n print('Alice')\nelse:\n print('Borys')", "def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\nn,a,b = iim()\nif (b-a)%2 == 0:\n if b-a == 1:\n print('Borys')\n else:\n print('Alice')\nelse:\n print('Borys')"]
['Wrong Answer', 'Accepted']
['s600631116', 's644024752']
[3060.0, 3060.0]
[17.0, 17.0]
[246, 247]
p03463
u027622859
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
["N, A, B = map(int, input().split())\nif A==1 and B==N:\n print('Borys')\nelse:\n if B-A == 2:\n print('Draw')\n elif (B-A)%2 == 0:\n print('Alice')\n else:\n print('Borys')", "N, A, B = map(int, input().split())\nif A==1 and B==A+1:\n print('Borys')\nelse:\n if (B-A)%2 == 0:\n print('Alice')\n elif (B-A)%2 == 1:\n print('Borys')\n else:\n print('Draw')"]
['Wrong Answer', 'Accepted']
['s954326192', 's402045615']
[3064.0, 3060.0]
[17.0, 18.0]
[196, 202]
p03463
u045939752
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['N,A,B=map(int,input().split())\nprint("Borys" if (B-A)%2 == 0 else "Alice")', 'N,A,B=map(int,input().split())\nprint("Borys" if (B-A)%2 == 1 else "Alice")']
['Wrong Answer', 'Accepted']
['s030961935', 's955619418']
[2940.0, 2940.0]
[18.0, 24.0]
[74, 74]
p03463
u057463552
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['import sys\nK = int(input())\nA = [int(x) for x in input().split()]\nA.reverse()\njmax, jmin = 2,2\n\nif A[0] != 2:\n print(-1)\n sys.exit()\n\n\n"""max"""\nfor i in range(0,K-1):\n drop_num = []\n for j in range(0,A[i]): \n if ( jmax + j ) % A[i+1] == 0:\n drop_num.append(j)\n\n if drop_num == []: \n print(-1)\n sys.exit()\n\n max_drop = max(drop_num)\n jmax = jmax + max_drop\n\njmax = jmax + A[K-1] -1\n\n\n"""min"""\nfor i in range(0,K-1):\n drop_num = []\n for j in range(0,A[i]): \n if ( jmin + j ) % A[i+1] == 0:\n drop_num.append(j)\n\n if drop_num == []: \n print(-1)\n sys.exit()\n\n min_drop = min(drop_num)\n jmin = jmin + min_drop\n\n\nprint(jmin, jmax)', 'N, A, B = map(int,input().split())\nif (B-1-A) % 2 == 0:\n print("Borys")\nelse:\n print("Alice")']
['Runtime Error', 'Accepted']
['s256562901', 's265223297']
[3064.0, 2940.0]
[17.0, 17.0]
[1005, 99]
p03463
u102960641
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['n,a,b = map(int, input().split())\nif b - a % 2 == 0:\n print("Alice")\nelif b - a % 2 == 1\n print("Borys")', 'n,a,b = map(int, input().split())\nif b - a % 2 == 0:\n print("Alice")\nelif b - a % 2 == 1\n print("Borys")', 'n,a,b = map(int, input().split())\nif b - a % 2 == 0:\n print("Alice")\nelif b - a % 2 == 1:\n print("Borys")', 'n,a,b = map(int, input().split())\nc = b-a\nif c % 2 == 0:\n print("Alice")\nelif c % 2 == 1:\n print("Borys")']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s254807099', 's832436942', 's898782798', 's139316421']
[2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 18.0, 18.0, 18.0]
[106, 106, 107, 107]
p03463
u125050519
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['N = input()\nA = input()\nB = input()\n\nres = ""\n\nif ((int)(B) - (int)(A))%2 == 0:\n res = "Alice"\nelse:\n res = "Borys"\n\nprint(res)\n', 'moji = input()\nmoji = moji.split(" ")\nN = moji[0]\nA = moji[1]\nB = moji[2]\n\nres = ""\n\nif ((int)(B) - (int)(A))%2 == 0:\n res = "Alice"\nelse:\n res = "Borys"\n\nprint(res)\n']
['Runtime Error', 'Accepted']
['s737241176', 's606112025']
[2940.0, 3060.0]
[17.0, 17.0]
[134, 172]
p03463
u136647933
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
["n,a,b=map(int,input().split())\nbet=abs(b-a)\nif bet%2==0:\n winner='ALice'\n else:\n winner='Borys'\n \nprint(winner)", "n,a,b=map(int,input().split())\nbet=abs(b-a)\nif bet%2==0:\n winner='Alice'\nelse:\n winner='Borys'\n \nprint(winner)"]
['Runtime Error', 'Accepted']
['s996780018', 's697644821']
[2940.0, 2940.0]
[17.0, 18.0]
[119, 117]
p03463
u148079233
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
["N, A, B = map(int, input().split())\n \nif (B - A) % 2 == 0:\n print('Borys')\nelse:\n print('Alice')", "N, A, B = map(int, input().split())\n \nif (B - A - 1) % 2 == 0:\n print('Borys')\nelse:\n print('Alice')"]
['Wrong Answer', 'Accepted']
['s235224680', 's261508663']
[2940.0, 2940.0]
[17.0, 18.0]
[98, 102]
p03463
u162612857
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['n, a, b = list(map(int(), input().split()))\nprint("Borys" if (b - a) % 2 == 1 else "Alice")', 'n, a, b = list(map(int, input().split()))\nprint("Borys" if (b - a) % 2 == 1 else "Alice")']
['Runtime Error', 'Accepted']
['s495832378', 's595443902']
[2940.0, 2940.0]
[18.0, 18.0]
[91, 89]
p03463
u187109555
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['N, A, B = map(int, input().split())\nif (A-B) % 2 == 0:\n print("Alice)\nelse:\n print("Borys")', 'N, A, B = map(int, input().split())\nif (A-B) % 2 == 0:\n print("Borys")\nelse:\n print("Alice")', 'N, A, B = map(int, input().split())\nif (A-B) % 2 == 0:\n print("Bolice")\nelse:\n print("Alice")', 'N, A, B = map(int, input().split())\nif (A-B) % 2 == 0:\n print("Alice")\nelse:\n print("Borys")']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s512471402', 's668127652', 's787079170', 's407674786']
[2940.0, 2940.0, 2940.0, 2940.0]
[18.0, 18.0, 17.0, 17.0]
[97, 98, 99, 98]
p03463
u200239931
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
['def getinputdata():\n\n array_result = []\n \n data = input()\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\n\nn = int(arr_data[0][0])\n\na = int(arr_data[0][1])\n\nb = int(arr_data[0][2])\n\nprint("Alice" if b-a%2==0 else "Borys")\n', 'def getinputdata():\n\n array_result = []\n \n data = input()\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n try:\n\n while flg:\n\n data = input()\n\n if(data != ""):\n \n array_result.append(data.split(" "))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n return array_result\n\narr_data = getinputdata()\n\n\nn = int(arr_data[0][0])\n\na = int(arr_data[0][1])\n\nb = int(arr_data[0][2])\n\nprint("Alice" if (b-a)%2==0 else "Borys")\n']
['Wrong Answer', 'Accepted']
['s542804191', 's817897669']
[3060.0, 3064.0]
[17.0, 17.0]
[625, 627]
p03463
u225388820
1,000
524,288
A game is played on a strip consisting of N cells consecutively numbered from 1 to N. Alice has her token on cell A. Borys has his token on a different cell B. Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once. The player who can't make a move loses, and the other player wins. Both players want to win. Who wins if they play optimally?
["n,a,b=map(int,input().split())\nif (b-a)%2==1:\n print('Alice')\nelse:\n print('Borys')", "n,a,b=map(int,input().split())\nif (b-a)%2==0:\n print('Alice')\nelse:\n print('Borys')"]
['Wrong Answer', 'Accepted']
['s633485244', 's859267415']
[2940.0, 2940.0]
[22.0, 18.0]
[85, 85]