Entries from 2016-05-01 to 1 month
https://www.hackerearth.com/april-circuits/algorithm/utkarsh-and-special-dfs/ Modifying some node u, changing a[ u ] to some new value x, the vis count of each node of subtree of u will be divided by the original a[ u ], and multiplied by …
https://www.hackerearth.com/april-circuits/algorithm/circ-bear-and-vectors/ Two vectors v1( a1, b1 ), v2( a2, b2 ) are perpendicular to each other iff ( v1 dot v2 ) = a1 * a2 + b1 * b2 = 0. And since ( ka, kb ) = k( a, b ) is parallel to (…
https://www.hackerearth.com/april-circuits/approximate/2b-bear-and-walk-1/ It is not difficult to come up to the maze solving left / right hand rule. www.youtube.com Since the path is connected, it will work. However, there are several dif…
https://www.hackerearth.com/april-circuits/algorithm/2a-bear-and-all-permutations-1/ We can simply simulate for each answer since n is only up to 12. However, it still takes a lot of time, and the number is extremely large, we will have to…
https://www.hackerearth.com/april-circuits/algorithm/circ-bear-and-leaderboard-1/ For clarity, everything here concerning to index will be 0 based. For example rank of some participant will be equal to the number of participants having sco…
https://www.hackerearth.com/april-circuits/algorithm/circ-bear-and-vowels-2/ Simply simulate as the description provides. #include <bits/stdc++.h> using namespace std; const int MAXS = 50 + 2; const string vowel = "aeiouy"; string s; void solve(){ int vo</bits/stdc++.h>…
Problem - D - Codeforces Edges are all weighted 1, so we can apply BFS for single source shortest path, for each node as source. This allows us to get all pairwise distances in O( n ^ 2 ). Since we are to find the maximum distance of path …
http://codeforces.com/contest/667/problem/C Misunderstood the problem, thought some valid suffix must be some substring of the prefix and failed... Seems like everyone else had no problem understanding that it actually only wanted us to co…