Search found 112 matches

by Yarin
Tue Nov 26, 2002 11:43 pm
Forum: C++
Topic: Old G++ version unacceptable
Replies: 4
Views: 3363

Also, I'm not sure you would want to use more advanced C++ features anyway, as I believe they will be unnecessarily slow because the compile with optimizations turned off. There are for instance several problems at UVA where you will time out if you use STL vector (without actually using the dynamic...
by Yarin
Tue Nov 26, 2002 5:25 am
Forum: C++
Topic: Grow Array Size
Replies: 13
Views: 5760

A pointer is simple an integer. When you do ptr=&b[4], ptr will contain the address to the fourth element in b, which is just a number. When you later free the b array, the value in ptr will of course not change - it will still contain the same number. However, now this pointer points to memory ...
by Yarin
Mon Nov 18, 2002 8:28 pm
Forum: Volume 103 (10300-10399)
Topic: 10381 - The Rock
Replies: 8
Views: 4511

The result of the first and last input is correct, but the second one is not a valid input. If your program actually gets an answer for that in any case, it's a bit strange, it should be infinite or something in that case.

There are no tricks in the problem nor the input really.
by Yarin
Fri Nov 15, 2002 2:12 am
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 44504

Ohhh... I guess I've never thought about that. Thanks :-)
by Yarin
Thu Nov 14, 2002 9:42 pm
Forum: Algorithms
Topic: Game Theory
Replies: 2
Views: 4397

This is the basic brute-force method which works on basically all game theory problems where you can enumerate all states of the game: 1. Start by finding all final states and mark them as a win or a loss and put these states in a queue (in 10404, that would be marking 0 as a loss) 2. Pop the front ...
by Yarin
Thu Nov 14, 2002 8:07 pm
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 44504

You start with the original sieve algorithm, like this: char isprime[MAX]; for(int i=0;i<MAX;i++) isprime =i>=2; for(int i=2;i<MAX;i++) if (isprime ) // i is a prime, so make all multiples of it non-prime for(int j=i*2;j<MAX;j+=i) isprime[j]=0; Then you realize you can store the data more compact si...
by Yarin
Wed Nov 13, 2002 1:26 am
Forum: Algorithms
Topic: Finding the heavier rectangle
Replies: 10
Views: 5028

Umm, complexity doesn't matter on input size. In any case, do you have any reference to that algorithm?
by Yarin
Tue Nov 12, 2002 10:55 pm
Forum: Algorithms
Topic: Finding the heavier rectangle
Replies: 10
Views: 5028

This is problem 108 as I'm sure you know, and I'm pretty certain it is a well established fact that you can't, in the general case, solve this faster than N^3. I'm afraid I have no idea how to prove this, but it seems like a standard problem so I think I should have heard if there's a N^2 solution.
by Yarin
Mon Nov 11, 2002 5:09 pm
Forum: Volume 103 (10300-10399)
Topic: 10387 - Billiard
Replies: 5
Views: 3064

There's no need to simulate the ball. Since you know the number of horizontal and vertical bounces, you know how far the ball has travelled in the horizontal and vertical direction. Just use pythagoras formula and divide with the ball speed.
by Yarin
Mon Nov 11, 2002 2:55 pm
Forum: Volume 104 (10400-10499)
Topic: 10410 - Tree Reconstruction
Replies: 13
Views: 10464

14 7 8 12 4 5 1 6 11 2 3 10 9 13 14 7 8 4 5 2 3 12 1 6 10 14 11 9 13 5 5 4 3 2 1 5 4 3 2 1 Try this. My (AC) program returns 1: 2: 3: 4: 5: 2 3 6: 10 7: 8 12 8: 4 5 9: 10: 14 11: 9 13 12: 1 6 11 13: 14: 1: 2: 3: 4: 5: 1 2 3 4 After I solved this problem in the contest, I noticed my program was wron...
by Yarin
Fri Nov 08, 2002 6:27 am
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 44504

My memory-tight sieve looks like this: #define MAXSIEVE 100000000 // All prime numbers up to this #define MAXSIEVEHALF (MAXSIEVE/2) #define MAXSQRT 5000 // sqrt(MAXSIEVE)/2 char a[MAXSIEVE/16+2]; #define isprime(n) (a[(n)>>4]&(1<<(((n)>>1)&7))) // Works when n is odd int i,j; memset(a,255,si...
by Yarin
Wed Nov 06, 2002 11:41 pm
Forum: Volume 103 (10300-10399)
Topic: 10399 - Optimus Prime
Replies: 14
Views: 6822

Huh?? c can get as big as 1693182318746371!! For a list of all maximal prime gaps, check out

http://www.utm.edu/research/primes/notes/GapsTable.html

Of course, I don't think that will help you very much in solving the problem...
by Yarin
Wed Nov 06, 2002 4:49 am
Forum: Volume 103 (10300-10399)
Topic: 10394 - Twin Primes
Replies: 101
Views: 44504

I wouldn't care too much about the low execution times some people get on some problems. In most cases this is either due some really crazy optimizations (like using inline assembly and tweaking input/output) or really big precalculated lookup tables. There are some people who seem to take a big del...
by Yarin
Mon Oct 28, 2002 6:27 pm
Forum: Volume 4 (400-499)
Topic: 420 - Supercomputer Selection, The Sequel
Replies: 4
Views: 2745

I simply calculate the volume below the three triangles, {a,b,c}, {b,d,c} and {c,d,(0,0,1)}. I never managed to get the answer in the sample output, no matter how I changed the order of triangles or permuted a,b,c,d.

But the problem description is just awful.
by Yarin
Sun Oct 27, 2002 9:26 pm
Forum: Volume 4 (400-499)
Topic: 420 - Supercomputer Selection, The Sequel
Replies: 4
Views: 2745

420 - Supercomputer Selection, The Sequel

I just wanted to point out that the sample output in this problem is wrong, it should be
2 336.83
Not many have submitted on this one, maybe it's because of this (?)

Go to advanced search