message stringlengths 2 45.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 254 108k | cluster float64 3 3 | __index_level_0__ int64 508 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekee... | instruction | 0 | 39,349 | 3 | 78,698 |
No | output | 1 | 39,349 | 3 | 78,699 |
Provide a correct Python 3 solution for this coding contest problem.
ACM countries have rivers that flow from east to west in the center. This river flows from the neighboring country in the west through the neighboring country in ACM to the neighboring country in the east, and the total length in ACM is K km. It is p... | instruction | 0 | 39,564 | 3 | 79,128 |
"Correct Solution:
```
while True:
n, m, k = (int(s) for s in input().split())
if (n, m, k) == (0, 0, 0):
break
t_out = [0.] * (k + m + 1)
tl_east = [0.] * (k + m + 1)
tl_west = [0.] * (k + m + 1)
for i in range(n):
xi, li, fi, di, udi = (int(s) for s in input().split())
... | output | 1 | 39,564 | 3 | 79,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
ACM countries have rivers that flow from east to west in the center. This river flows from the neighboring country in the west through the neighboring country in ACM to the neighboring country i... | instruction | 0 | 39,565 | 3 | 79,130 |
No | output | 1 | 39,565 | 3 | 79,131 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,887 | 3 | 79,774 |
Tags: math
Correct Solution:
```
n, m = map(int, input().split())
ans = 1
base = 3
while n != 0:
if n & 1:
ans = (ans * base) % m
base = (base * base) % m
n >>= 1
ans = (ans + m - 1) % m
print(ans)
``` | output | 1 | 39,887 | 3 | 79,775 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,888 | 3 | 79,776 |
Tags: math
Correct Solution:
```
import math
def powerk (a,x,y):
if(x==1):
return(a)
elif(x<=0):
return(1)
else:
if (a<=0):
return(0)
y0=math.ceil(math.log(y,a))
if(y0<=0):
return(a**x)
if (x<y0):
return((a**x)%y)
... | output | 1 | 39,888 | 3 | 79,777 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,889 | 3 | 79,778 |
Tags: math
Correct Solution:
```
n,m=map(int,input().split());print((pow(3,n,m)-1)%m)
``` | output | 1 | 39,889 | 3 | 79,779 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,890 | 3 | 79,780 |
Tags: math
Correct Solution:
```
def fastpow(mod,times):
if times==1:
return 3
else:
if (times%2):
now=fastpow(mod,(times-1)/2)%mod
return (now*now*3)%mod
else:
now = fastpow(mod, (times ) / 2) % mod
return (now * now ) % mod
n,m=map(int, i... | output | 1 | 39,890 | 3 | 79,781 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,891 | 3 | 79,782 |
Tags: math
Correct Solution:
```
def modpow(a, b, n):
if b == 0:
return 1
if b == 1:
return a % n
tmp = modpow(a, b // 2, n) % n
tmp = (tmp * tmp) % n
if b % 2 == 1:
return (tmp * a) % n
else:
return tmp
def main():
n, m = map(int, input().split())
ans =... | output | 1 | 39,891 | 3 | 79,783 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,892 | 3 | 79,784 |
Tags: math
Correct Solution:
```
import sys
import string
import math
import heapq
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction
def mi(s):
return map(int, s.strip().split())
def lmi(s):
return list(mi(s))
def tmi(s):
re... | output | 1 | 39,892 | 3 | 79,785 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,893 | 3 | 79,786 |
Tags: math
Correct Solution:
```
def quick_algorithm(a,b,c):
a=a%c
ans=1
while b!=0:
if b&1:
ans=(ans*a)%c
b>>=1
a=(a*a)%c
return ans
n,m=map(int,input().split())
print((quick_algorithm(3,n,m)-1)%m)
``` | output | 1 | 39,893 | 3 | 79,787 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. Th... | instruction | 0 | 39,894 | 3 | 79,788 |
Tags: math
Correct Solution:
```
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
# from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left ... | output | 1 | 39,894 | 3 | 79,789 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,895 | 3 | 79,790 |
Yes | output | 1 | 39,895 | 3 | 79,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,896 | 3 | 79,792 |
Yes | output | 1 | 39,896 | 3 | 79,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,897 | 3 | 79,794 |
Yes | output | 1 | 39,897 | 3 | 79,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,898 | 3 | 79,796 |
Yes | output | 1 | 39,898 | 3 | 79,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,899 | 3 | 79,798 |
No | output | 1 | 39,899 | 3 | 79,799 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,900 | 3 | 79,800 |
No | output | 1 | 39,900 | 3 | 79,801 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,901 | 3 | 79,802 |
No | output | 1 | 39,901 | 3 | 79,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave p... | instruction | 0 | 39,902 | 3 | 79,804 |
No | output | 1 | 39,902 | 3 | 79,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Imagine an n Γ m grid with some blocked cells. The top left cell in the grid has coordinates (1, 1) and the bottom right cell has coordinates (n, m). There are k blocked cells in the grid and ot... | instruction | 0 | 39,905 | 3 | 79,810 |
No | output | 1 | 39,905 | 3 | 79,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,906 | 3 | 79,812 |
Tags: brute force, greedy, implementation
Correct Solution:
```
t,sx,sy,ex,ey =map(int,input().split())
dire=input()
p=0
for i in range(0,t):
if dire[i]=='S'and ey<sy:
sy-=1
elif dire[i]=='N'and ey>sy:
sy+=1
elif dire[i]=='E' and ex>sx:
sx+=1
elif dire[i]=='W' and ex<sx:
... | output | 1 | 39,906 | 3 | 79,813 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,907 | 3 | 79,814 |
Tags: brute force, greedy, implementation
Correct Solution:
```
# python2 or 3
import sys, threading, os.path
import collections, heapq, math,bisect
import string
from platform import python_version
sys.setrecursionlimit(10**6)
threading.stack_size(2**27)
def main():
if os.path.exists('input.txt'):
input ... | output | 1 | 39,907 | 3 | 79,815 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,908 | 3 | 79,816 |
Tags: brute force, greedy, implementation
Correct Solution:
```
t, sx, sy, ex, ey = [int(x) for x in input().split()]
dir = input()
allow = []
if ex - sx > 0:
allow.append('E')
elif ex - sx < 0:
allow.append('W')
if ey - sy > 0:
allow.append('N')
elif ey - sy < 0:
allow.append('S')
curr = [sx, sy]
en... | output | 1 | 39,908 | 3 | 79,817 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,909 | 3 | 79,818 |
Tags: brute force, greedy, implementation
Correct Solution:
```
t,x,y,u,v = map(int,input().split())
dic = {}
dic['N'],dic['S'] = (v-y,0) if v>=y else (0,y-v)
dic['E'],dic['W'] = (u-x,0) if u>=x else (0,x-u)
inp = str(input())
for i in range(t):
dic[inp[i]]-=1
if dic['N']<1 and dic['S'] < 1 and dic['E'] < 1 and... | output | 1 | 39,909 | 3 | 79,819 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,910 | 3 | 79,820 |
Tags: brute force, greedy, implementation
Correct Solution:
```
# Author Kmoussai
import sys
import math
import random
'''
i = 0
while i < n:
i += 1
map(int, input().split())
def pgcd(a, b):
if b == 0:
return a
return pgcd(b, a%b)
'''
if len(sys.argv) >= 2:
if sys.argv[1] == 'LOCAL':... | output | 1 | 39,910 | 3 | 79,821 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,911 | 3 | 79,822 |
Tags: brute force, greedy, implementation
Correct Solution:
```
def main():
ind = {'E': (1, 0), 'S': (0, -1), 'W': (-1, 0), 'N': (0, 1), '#': (0, 0)}
t, sx, sy, tx, ty = map(int, input().split())
s = str(input())
if sx == tx and sy == ty:
print('0')
return
for i in range(0, t):
... | output | 1 | 39,911 | 3 | 79,823 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,912 | 3 | 79,824 |
Tags: brute force, greedy, implementation
Correct Solution:
```
X = list(map(int, input().split()))
XTotal, YTotal = X[-2] - X[1], X[-1] - X[2]
S, Cnt = input(), 0
for i in S:
if XTotal == 0 and YTotal == 0:
print(Cnt)
exit()
if i in 'EW':
if XTotal > 0 and i == 'E': XTotal -= 1
... | output | 1 | 39,912 | 3 | 79,825 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (... | instruction | 0 | 39,913 | 3 | 79,826 |
Tags: brute force, greedy, implementation
Correct Solution:
```
t,sx,sy,ex,ey=map(int,input().split())
L=list(input())
time=0
for i in L:
if i=='W' and sx>ex:
sx-=1
elif i=='E' and sx<ex:
sx+=1
elif i=='N' and sy<ey:
sy+=1
elif i=='S' and sy>ey:
sy-=1
time+=1
if s... | output | 1 | 39,913 | 3 | 79,827 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,914 | 3 | 79,828 |
Yes | output | 1 | 39,914 | 3 | 79,829 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,915 | 3 | 79,830 |
Yes | output | 1 | 39,915 | 3 | 79,831 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,916 | 3 | 79,832 |
Yes | output | 1 | 39,916 | 3 | 79,833 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,917 | 3 | 79,834 |
Yes | output | 1 | 39,917 | 3 | 79,835 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,918 | 3 | 79,836 |
No | output | 1 | 39,918 | 3 | 79,837 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,919 | 3 | 79,838 |
No | output | 1 | 39,919 | 3 | 79,839 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,920 | 3 | 79,840 |
No | output | 1 | 39,920 | 3 | 79,841 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, w... | instruction | 0 | 39,921 | 3 | 79,842 |
No | output | 1 | 39,921 | 3 | 79,843 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.
In that country there are n islands and m bri... | instruction | 0 | 40,063 | 3 | 80,126 |
No | output | 1 | 40,063 | 3 | 80,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.
In that country there are n islands and m bri... | instruction | 0 | 40,064 | 3 | 80,128 |
No | output | 1 | 40,064 | 3 | 80,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.
In that country there are n islands and m bri... | instruction | 0 | 40,065 | 3 | 80,130 |
No | output | 1 | 40,065 | 3 | 80,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.
In that country there are n islands and m bri... | instruction | 0 | 40,066 | 3 | 80,132 |
No | output | 1 | 40,066 | 3 | 80,133 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,159 | 3 | 80,318 |
Yes | output | 1 | 40,159 | 3 | 80,319 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,160 | 3 | 80,320 |
Yes | output | 1 | 40,160 | 3 | 80,321 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,161 | 3 | 80,322 |
Yes | output | 1 | 40,161 | 3 | 80,323 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,162 | 3 | 80,324 |
Yes | output | 1 | 40,162 | 3 | 80,325 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,163 | 3 | 80,326 |
No | output | 1 | 40,163 | 3 | 80,327 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,164 | 3 | 80,328 |
No | output | 1 | 40,164 | 3 | 80,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,165 | 3 | 80,330 |
No | output | 1 | 40,165 | 3 | 80,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.
Arkady goes to the riverside each day and makes a mark on the side of ... | instruction | 0 | 40,166 | 3 | 80,332 |
No | output | 1 | 40,166 | 3 | 80,333 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.
Max is a young biologist. For n days he watched a specific shark, an... | instruction | 0 | 40,167 | 3 | 80,334 |
Tags: brute force, data structures, dsu, trees
Correct Solution:
```
# https://codeforces.com/problemset/problem/982/D
class Union:
def __init__(self, n):
self.p = {i:i for i in range(n)}
self.rank = {i:1 for i in range(n)}
def find(self, x):
if x < 0: return x
... | output | 1 | 40,167 | 3 | 80,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.
Max is a young biologist. For n days he watched a specific shark, an... | instruction | 0 | 40,168 | 3 | 80,336 |
Tags: brute force, data structures, dsu, trees
Correct Solution:
```
def union(x,y,a,each):
x1=x
y1=y
while(a[x]>0):
x=a[x]
while(a[y]>0):
y=a[y]
each[-1*a[x]]-=1
each[-1*a[y]]-=1
#print('new size ',-1*(a[x]+a[y]), ' x ',x,' y ',y)
each[-1*(a[x]+a[y])]+=1
if... | output | 1 | 40,168 | 3 | 80,337 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.