Thanks bro

Active In

Competitive Programming

Web Development

Featured Contributions

comment in this discussion

comment in this discussion

import sysclass Tree:def __init__(self, n):self.size = n + 1self.cur_size = 0self.tree = [[] for _ in range(self.size)]self.iscentroid = [False] * self.sizeself.ctree = [[] for _ in range(self.size)]self.characters=[None for _ in range(self.size)]def dfs(self, src, visited, subtree):visited[src] = Truesubtree[src] = 1self.cur_size += 1for adj in self.tree[src]:if not visited[adj] and not self.iscentroid[adj]:self.dfs(adj, visited, subtree)subtree[src] += subtree[adj]def findCentroid(self, src, visited, subtree):iscentroid = Truevisited[src] = Trueheavy_node = 0

Read more… (29 words)

comment in this discussion

def bs(start,end,key):while(start<end):mid=(start+end)//2if key>=arr[mid][0]:start=start+1else:end=midreturn startfor _ in range(int(input())):arr=[]n=int(input())for i in range(n):a,b,c=map(int,input().split())b=a+barr.append([a,b,c])arr.sort()presum=[0 for i in range(n)]presum[0]=arr[0][2]for i in range(1,n):presum[i]=presum[i-1]+arr[i][2]

Read more… (10 words)

comment in this discussion

r,c,d=map(int,input().split())arr=[]for i in range(r):temp=list(map(int,input().split()))arr.append(temp)def isvalid(x,y):return x<r and y<c and arr[x][y]!=0memo={}def solve(i,j,step,direction,d):if not isvalid(i,j):return 0if i==r-1 and j==c-1:return 1if (i,j,step,direction,d) in memo:return memo[(i,j,step,direction,d)]ans=0if direction==1:if step<d:ans=(ans+solve(i,j+1,step+1,1,d))%2011

Read more…

comment in this discussion

class PathNode:def __init__(self, row, col, st_x, st_y, p_count=0):self.x = rowself.y = colself.pathCount = p_countdef __str__(self):return str(self.x) + " | " + str(self.y) + " | " + str(self.pathCount)class GraphUtil:def __init__(self, mat, R,C, d):self.mat = matself.R = Rself.C = Cself.d = dself.tab = {}def isValidMove(self, r, c, blockVal):return r < self.R and c < self.C and self.mat[r][c] != blockValdef possbilePathUtil(self, r, c, blockVal, step,direction):

Read more…

comment in this discussion

comment in this discussion

can you provide python implementation of merge sort tree I dont know c++.I did find not any implementation of merge sort tree in python

Read more… (24 words)

comment in this discussion

can somebody provide pythonic sollution of problem templeq spoj

Read more… (9 words)

comment in this discussion

Where can I get python implementation of the augmented segment trees .I dont know cpp.

Read more… (15 words)

comment in this discussion