Re: [gcj] Any Optimal Solution for "Round 1A: Minimum Scalar Product" Problem?

2016-04-13 Thread wonjun
The main idea is the rearrangement inequality; check out the contest analysis ^^. On 14 Apr 2016 14:13, "akhil patel" wrote: > Hi, > > As i have been doing this problem in python using my own method which > computes for the all possible permutations and finding the scalar product > for all the ve

[gcj] Easy way to do Java I/O?

2014-03-31 Thread wonjun
Hey guys, I normally submit my programs in Python, but for this time I'd like to do a mix of both Python and Java. I wonder if this is a good way to do it: import java.io.*; public class Pogo { public String solve(int x, int y) { . // returns the answer... } public static void main(String[]

Re: [gcj] How to take input in topcoder problem

2013-07-20 Thread wonjun
I normally go to the view section and copy everything. For instance if it was the problem of SRM 584 Div 1 Egalitarianism, I would copy the following: {"NYN", "YNY", "NYN"}, 10 20 Passed {"NN", "NN"}, 1 -1 Passed etc and put it in a file, say EgalitarianismTest.txt Then I read the file, like t

Re: [gcj] Problem in ROUND 1A ( c ) 2008

2013-07-13 Thread wonjun
Xn is an (even) integer, and what we really want to find is the last three digits of (Xn - 1) >From Xn = 2*a_n, so what we really seek is (2*a_n - 1) mod 1000. (more formally, an element of Z/1000Z) If I know correctly, Python will give correct output if one writes like this (i.e. 2*a_n - 1 mod 10

Re: [gcj] GCJ 2009 Round 2, Digging Problem

2013-07-04 Thread wonjun
> only have to consider this case once in going to the next level, if there > was one. If there were ways to reach this state that had different numbers > of spaces dug out, you would keep the one with the fewest spaces dug. > > > > > On Wed, Jul 3, 2013 at 1:55 AM, wonjun w

Re: [gcj] GCJ 2009 Round 2, Digging Problem

2013-07-02 Thread wonjun
, and where within the hole that you are, and the state > has an accompanying score, the minimum number of spaces you need to dig to > reach the state. Process all the ones in one row, then all the ones in the > next row and so on. > > > > On Tue, Jul 2, 2013 at 4:10 PM, wonjun wrot

[gcj] GCJ 2009 Round 2, Digging Problem

2013-07-02 Thread wonjun
I have tried to solve Digging Problem and have gotten quite stuck. When I read the problem, I thought Dijkstra's Algorithm would beat it, and have tried to do so. But it seems my implementation has many flaws, and is not giving the

Re: [gcj] Re: Can anyone pls provide me idea or partial solution on this problem in c++ without using STL?

2013-05-12 Thread wonjun
That doesn't matter. They're both excellent courses and their objectives are very much different. On May 12, 2013 10:22 PM, "Vaibhav Tulsyan" wrote: > Is Tim Roughgarden's course better than Sedgewick's? > > > On Sun, May 12, 2013 at 10:13 PM, Stanislav Zholnin < > stanislav.zhol...@gmail.com> w

[gcj] BullsEye Problem - Python Troubleshooting help!

2013-04-27 Thread wonjun
I used the following logic for the problem - Let k be the required answer. Then, (R+1)^2 - R^2 = 2R + 1 amount of paint to paint the first circle (R+3)^2 - (R+2)^2 = 2R + 5 amount of paint to paint the second circle. ... and so on - we get total k equations. Now, adding the k equations, and putt

Re: [gcj] Python IO help

2013-04-15 Thread wonjun
: >> >> python mySolution.py < A-small-attempt85.in > a.out >> >> This will treat that in file as standard in and output to the out file. >> >> Sent from my iPad >> >> On 15 Apr 2013, at 06:27, wonjun wrote: >> >> Hello All, >>

[gcj] Python IO help

2013-04-14 Thread wonjun
Hello All, I mainly code in Python, and is quite confused with the IO part. Well I normally do the following for IO: f = open('filename','r') a = f.read() b = a.split('\n') Now, depending on the problem at hand, I use a for loop / while loop to look over all cases and solve them accordingly. I b

Re: [gcj] round 2 2009, problem A.

2012-04-09 Thread wonjun
As far as I understand, it says "1 values should be below or on the diagonal", (*) so we can do the following: 1) 1110 1100 1100 1000 2) 1110 1100 1000 1100 (ie R3 <-> R4) 3) 1100 1110 1000 1100 (R1 <-> R2) 4) 1100 1000 1110 1100 (R2 <-> R3) 5) 1000 1100 1110 1100 (R1 <-> R2) Note that the