Search found 169 matches

by junjieliang
Sun Aug 13, 2006 5:30 am
Forum: Algorithms
Topic: IOI 06 practice problem: cutting a grid
Replies: 0
Views: 1142

IOI 06 practice problem: cutting a grid

Problem statement: http://www.ioi2006.org/practice/cutting_a_grid.pdf My friend and I are wondering about how to do this problem. Can someone tell me if this greedy solution works? It sounds fine to me... 1. First you assume the white area is to the left, and you divide the grid turning as many time...
by junjieliang
Sat Jun 26, 2004 4:48 am
Forum: C
Topic: Exchanging two integers
Replies: 5
Views: 3010

The third way that I know of is similar to the addition/subtraction method:

a = a * b;
b = a / b;
a = a / b;

Well then again this method is real stupid... you can get overflow and precision errors very easily. Just for fun I knowing it, but don't use it in real programs! :)
by junjieliang
Wed Apr 21, 2004 4:31 pm
Forum: C
Topic: Efficiency
Replies: 6
Views: 3083

Whao... thanks everyone for their replies... quite surprised that so many people bothered to code test programs. :lol:

Thanks again.
by junjieliang
Sun Apr 18, 2004 2:40 pm
Forum: C
Topic: Efficiency
Replies: 6
Views: 3083

Efficiency

Hi, I have this question that's just out of curiosity. Which of the following code is more efficient? for (i = 0; i < 10000; i++) { if (i % 5 == 0) b++; a++; } or for (i = 0; i < 10000; i++) { count++; if (count == 5) { b++; count = 0; } a++; } In short, does multiplication / division / modulus use ...
by junjieliang
Sun Apr 18, 2004 2:30 pm
Forum: Volume 101 (10100-10199)
Topic: 10160 - Servicing Stations
Replies: 20
Views: 13301

Hmm... if you implemented all the heuristics listed you should get a better runtime. Try checking through your code and see if you have anything that would take a long time to run. An example of useless redundancy could be like: for (i = 0; i < 1000000; i++) a = i; when you could just have a = 99999...
by junjieliang
Sun Apr 18, 2004 2:20 pm
Forum: Volume 5 (500-599)
Topic: 561 - Jackpot
Replies: 7
Views: 3222

Instead of running through everything in O(n^3) time, consider using some maths to do the calculations.
by junjieliang
Thu Apr 15, 2004 4:31 pm
Forum: Volume 101 (10100-10199)
Topic: 10160 - Servicing Stations
Replies: 20
Views: 13301

This problem is quite difficult... it requires a lot of pruning... but it is possible... :D Try these suggestions: - Find all "dominating nodes", and eliminate the rest. Let A and B be the set of nodes adjacent to node a and b respectively. Let a node be connected to itself. If A is a subset of B, t...
by junjieliang
Sat Mar 27, 2004 7:43 pm
Forum: Volume 6 (600-699)
Topic: 624 - CD
Replies: 77
Views: 33357

I think it should be "1 3 2 1 sum: 7", but cyfra had a typo. Btw, the way I see it "tracks do not repeat" does not mean the length, just that you cannot use the same track more than once.
by junjieliang
Sat Feb 21, 2004 5:06 pm
Forum: Volume 103 (10300-10399)
Topic: 10342 - Always Late
Replies: 25
Views: 10983

Yes your output is correct. Have you tried reading this post?

http://online-judge.uva.es/board/viewto ... highlight=
by junjieliang
Wed Jan 28, 2004 4:34 pm
Forum: Volume 6 (600-699)
Topic: 668 - Parliament
Replies: 12
Views: 4373

Hmm okay... now it doesn't seem as easy... :D

I'm thinking of a O(n^3) DP solution, but I suppose that is too slow. Am I on the right track at all (like maybe I need to optimise the DP), or you need other methods to solve this problem (maths / smart brute force search / etc)?

Thanks.
by junjieliang
Sat Jan 24, 2004 6:36 am
Forum: Volume 6 (600-699)
Topic: 623 - 500!
Replies: 187
Views: 43816

Zhao Le: I don't really know much about DP except using Matrix How do you use matrix to find factorials? Btw for this problem would there be TLE/MLE if we just precalculate all factorials and store the numbers in arrays? I haven't tried this yet but if the memory used is not too great it sounds lik...
by junjieliang
Sun Jan 04, 2004 5:16 am
Forum: Volume 6 (600-699)
Topic: 668 - Parliament
Replies: 12
Views: 4373

668 Parliament - Clarifications

I think I don't understand this problem. From what I see, there is no special checker for this problem, but for the sample input (31) why is the output 2 3 5 6 7 8? Can't it be 1 3 5 6 7 9 as well? I couldn't find anything in the problem that will make the solution unique. Could someone who has solv...
by junjieliang
Sun Dec 21, 2003 1:25 pm
Forum: Volume 6 (600-699)
Topic: 626 - Ecosystem
Replies: 8
Views: 4921

I don't think the statement is found anywhere. The problem setter probably thought it obvious that a species cannot consume itself. Of course test cases on the OJ rarely fit into actual real life conditions, but I guess this problem does. :lol:
by junjieliang
Sat Dec 20, 2003 6:03 am
Forum: Volume 6 (600-699)
Topic: 626 - Ecosystem
Replies: 8
Views: 4921

My output:

1 2 3
3 2 1
total:2

The three numbers on each line should be different from each other.
by junjieliang
Thu Dec 18, 2003 8:37 am
Forum: Volume 1 (100-199)
Topic: 180 - Eeny Meeny
Replies: 34
Views: 9709

Ok so that's where the odd number comes in. By the way I think I figured out why the answer must be less than half the lower bound. The question never numbered the positions, just that you have to find how many position away from Mxgobgwq. In short 1 can mean position 1 left or 1 right. Therefore, i...

Go to advanced search