Questions asked by geek_geekhttps://discuss.codechef.com/questions/asked-by/44486/geek_geek/?type=rssQuestions asked by <a href="/users/44486/geek_geek" >geek_geek</a>enSat, 30 Apr 2016 23:09:38 +0530Improve my level in Competetive programming?https://discuss.codechef.com/questions/71817/improve-my-level-in-competetive-programming<p>I have been doing competetive programming for the past six to eight months,i seem to be struck in a level and i could move forwards.I see myself in the same rating/ranking for quite sometime.
i paricipate in codechef long challanges and mosstly do 4-5 correctly and 1 partially and a challage question</p>
<p>Do i need to know some advanced algorithms or i just need more practice</p>
<p>these are my handles</p>
<p><a href="http://codeforces.com/profile/geek_geek">http://codeforces.com/profile/geek_geek</a></p>
<p><a href="http://www.codechef.com/users/geek_geek">http://www.codechef.com/users/geek_geek</a></p>
<p><a href="https://www.hackerrank.com/Rajnikanth">https://www.hackerrank.com/Rajnikanth</a></p>
<p>as you can see my rating is same for quite some time, and dont know how to advance in this.</p>
<p>is practicing set of problems from topcoder/codechef a good idea? and which of thse two sites is better for practice??</p>geek_geekWed, 17 Jun 2015 10:54:38 +0530https://discuss.codechef.com/questions/71817/improve-my-level-in-competetive-programmingbegginerpracticenewbieJune Cook Off :ANKPAREN - NZEC in Python Forhttps://discuss.codechef.com/questions/72072/june-cook-off-ankparen-nzec-in-python-for<p>What causes NZEC in python
I submitted a code in python , i tested in Codechef IDE which gave appropriate output
when i submitted the same for the problem it gave me an NZEC</p>
<p>When i just wrote the same algo code in C++ 4.92 it gave me AC</p>
<p>Here is the link</p>
<p>Python : <a href="http://www.codechef.com/viewsolution/7261753">http://www.codechef.com/viewsolution/7261753</a></p>
<p>C++ : <a href="http://www.codechef.com/viewsolution/7262326">http://www.codechef.com/viewsolution/7262326</a></p>geek_geekMon, 22 Jun 2015 12:24:00 +0530https://discuss.codechef.com/questions/72072/june-cook-off-ankparen-nzec-in-python-fornzecpython2.7c++NOWAYS Editorialhttps://discuss.codechef.com/questions/72457/noways-editorial<h1>Problem Link : <a href="http://www.codechef.com/HOCO2015/problems/NOWAYS">Contest</a> <a href="http://www.codechef.com/problems/NOWAYS/">Practice</a></h1>
<p><strong>Author and Editorialist</strong> : Arun Prasad <a href="http://www.codechef.com/users/geek_geek">geek_geek</a></p>
<h1>Difficulty:</h1>
<p>Easy</p>
<h1>PREREQUISITES:</h1>
<p>Modular Arithmetic,Combinatorics,Repeated Squaring</p>
<h1>PROBLEM</h1>
<p>Given n items , find number of ways to choose k different items.</p>
<h1>QUICK EXPLANATION</h1>
<p>You have to find the value of nCk it will give you number of ways of choosing k items from n items
print nCk % mod (mod = 1000000007)</p>
<h1>EXPLANATION</h1>
<p>nck = (n!)/((n-k)! * k!)</p>
<p>now you cannot store n! in an array as it can be very big instead
you can store n!%mod in an array
since mod is a prime number you have to use <a href="https://en.wikipedia.org/wiki/Fermat's_little_theorem">fermat's theorem</a> to calculate the value of modular inverse of ((k!)%mod) and ((n-k)!%mod)</p>
<p>store the value of n!%mod in an array , and calculate inverse factorial for each n by using the formula</p>
<p>inv_factorial(n) = exp(n,mod-2,mod) (use repeated squaring for faster answers)</p>
<p>store all in an array</p>
<p>if n is greater tha k :
nCk = (fact(n)<em>inv_fact(n-k)</em>inv_fact(k))%mod</p>
<p>if n is lesser than k</p>
<p>You cannot choose k items from n if k is greater than n</p>
<p>hence answer is 0</p>
<h1>Solutions : <a href="http://www.codechef.com/viewsolution/7304886">Author's Solution</a></h1>geek_geekMon, 29 Jun 2015 18:40:59 +0530https://discuss.codechef.com/questions/72457/noways-editorialhoco2015nowaysnumberofwayseasyeditorialMQRY Editorialhttps://discuss.codechef.com/questions/72460/mqry-editorial<h1>Problem Link : <a href="http://www.codechef.com/problems/MQRY/">Contest</a> <a href="http://www.codechef.com/HOCO2015/problems/MQRY">Practice</a></h1>
<p><strong>Author and Editorialist :</strong> <a href="http://www.codechef.com/users/geek_geek">Arun Prasad</a></p>
<h1>DIFFICULTY:</h1>
<p>EASY</p>
<h1>PREREQUISITES:</h1>
<p>Segment Trees</p>
<h1>PROBLEM:</h1>
<p>Given the range of indexes print the difference between the largest and smallest value in the given range</p>
<h1>EXPLANATION:</h1>
<p>Create a segment tree for the given array, for each node in the segment tree maintain two variable, one for the smallest value in the sements range and other one for largest value in the segments range.</p>
<h1>Author's Solution :</h1>
<p><a href="http://www.codechef.com/viewsolution/7304942">Link For Authors Solution</a></p>geek_geekMon, 29 Jun 2015 19:02:08 +0530https://discuss.codechef.com/questions/72460/mqry-editorialsegment-treehoco2015mqryeasyeditorialTopcoder Vs Codeforces ?https://discuss.codechef.com/questions/75312/topcoder-vs-codeforces<p>Which of the two sites is best for practicing for short contest?
<br>And which of the two has more quality problems?
<br>Does TopCoder has problems on Advanced Data Structure like Segment trees, Trie etc?</p>
<p><br><b>Thanks</b></p>geek_geekMon, 21 Sep 2015 23:45:58 +0530https://discuss.codechef.com/questions/75312/topcoder-vs-codeforcestopcodercodeforcesFEB16 Long : SEATLhttps://discuss.codechef.com/questions/79267/feb16-long-seatl<p><strong>Complexity : O(Number of Distinct elements in matrix * N)</strong></p>
<p><strong>Concepts : Maps , sets .</strong></p>
<p>While a lot of people might have used O(NM*(N+M)) approach and recieved TLE even for subtask 1.
The number of test cases are not specified for each subtask.</p>
<p>Now instead of generating the count matrix , that is the maximum count of each element in that row+coloumn,
we would rather do it number by number.Its given that the numbers are between 1 to 10^6 or we can say the maximum number of distinct elements in the matrix can be atmost N*M ,</p>
<p>We will have map data structure to store the coordinates of each element in the matrix.
And from this we can find the length of the largest cross,and then print maximum length of cross of all elements.</p>
<p>Here is my working code in python : <a href="https://www.codechef.com/viewsolution/9414783">Solution</a></p>geek_geekMon, 15 Feb 2016 17:41:50 +0530https://discuss.codechef.com/questions/79267/feb16-long-seatllong-contestColours in Codechef Profile?https://discuss.codechef.com/questions/80611/colours-in-codechef-profile<p>I taught of this idea of introducing colours in codechef profile like Red , Yellow , green,blue as in Codeforces and Topcoder. This will intoduce more competition among coders.</p>geek_geekFri, 01 Apr 2016 11:44:20 +0530https://discuss.codechef.com/questions/80611/colours-in-codechef-profileprofilerankingscodechefTopCoder Arena not working?https://discuss.codechef.com/questions/80973/topcoder-arena-not-working<p>Recently i updated to windows 10 and my java version , ever since then it started blocking Topcoder Java applet because of security reason?</p>
<p>Does anyone here have a fix for this?
<img alt="alt text" src="https://discuss.codechef.com/upfiles/topcoder_app.png">
Thanks.!</p>geek_geekFri, 15 Apr 2016 19:17:06 +0530https://discuss.codechef.com/questions/80973/topcoder-arena-not-workingtopcoderLTIME35 - KSUMhttps://discuss.codechef.com/questions/81201/ltime35-ksum<p>This problem can be solved by using a priority queue.</p>
<p>My solution : <a href="https://www.codechef.com/viewsolution/9984949">https://www.codechef.com/viewsolution/9984949</a></p>
<p>Idea is keep a pointer from each element to the last element , and decrement the pointer to the previous element if the subbarray sum is popped out.</p>
<p>To do this we can use a priority queue , pop out and print the largest sum and then modify the pointer and push it back to the queue.</p>geek_geekSat, 30 Apr 2016 23:09:38 +0530https://discuss.codechef.com/questions/81201/ltime35-ksumlunch-time