Search found 85 matches

by Igor9669
Mon Oct 04, 2010 1:27 pm
Forum: Volume 118 (11800-11899)
Topic: 11855 - Buzzwords
Replies: 21
Views: 5634

Re: 11855 - Buzzwords

Yes!

Code: Select all

long long getHash(string s)
{
const int p = 31;
long long hash = 0, p_pow = 1;
for (int i=0; i<s.length(); ++i)
{
	hash += (s[i] - 'a' + 1) * p_pow;
	p_pow *= p;
}
return hash;
}
by Igor9669
Mon Oct 04, 2010 12:43 pm
Forum: Volume 118 (11800-11899)
Topic: 11833 - Route Change
Replies: 13
Views: 4054

Re: 11833 - Route Change

You need to find the shortest path from one city to another with a certain condition!
by Igor9669
Mon Oct 04, 2010 10:45 am
Forum: Volume 118 (11800-11899)
Topic: 11855 - Buzzwords
Replies: 21
Views: 5634

Re: 11855 - Buzzwords

I use hash in my solution!
by Igor9669
Mon Oct 04, 2010 8:33 am
Forum: Volume 118 (11800-11899)
Topic: 11857 - Driving Range
Replies: 21
Views: 7959

Re: 11857 - Driving Range

Read about MST (minimal spanning tree)!
by Igor9669
Fri Oct 01, 2010 2:58 pm
Forum: Volume 118 (11800-11899)
Topic: 11838 - Come and Go
Replies: 22
Views: 7563

Re: 11838 - Come And Go

May be bad tests there....((
Or you make a mistake in complexity of your algo...
Your implementation with queue got TLE,because it's O(N^3)!
by Igor9669
Fri Oct 01, 2010 2:44 pm
Forum: Volume 118 (11800-11899)
Topic: 11838 - Come and Go
Replies: 22
Views: 7563

Re: 11838 - Come And Go

I couldn't belive that Floyd could get Ac here....
it complexity O(n^3), where n=2000, how it could be pass at 2 sec???
by Igor9669
Fri Oct 01, 2010 2:14 pm
Forum: Volume 118 (11800-11899)
Topic: 11838 - Come and Go
Replies: 22
Views: 7563

Re: 11838 - Come And Go

Certanly you will get TLE on this problem with Floyd!

It could be solve with simple dfs or bfs with little modification!
by Igor9669
Fri Oct 01, 2010 10:46 am
Forum: Volume 118 (11800-11899)
Topic: 11833 - Route Change
Replies: 13
Views: 4054

Re: 11833 - Route Change

I got it!))
It works ok,sorry!))
by Igor9669
Fri Oct 01, 2010 9:12 am
Forum: Volume 118 (11800-11899)
Topic: 11833 - Route Change
Replies: 13
Views: 4054

11833 - Route Change

Hi! Could somebody tell to me what is wrong with my algo to this problem??? Algo: Construct a graph,delete all edges that make a service route. Than one of the standart algo to find a shortest path form city where the vehicle was taken for repair to all others. Then find the answer! Simple test and ...
by Igor9669
Sun May 02, 2010 12:11 pm
Forum: Volume 117 (11700-11799)
Topic: 11774 - Doom's Day
Replies: 10
Views: 3396

Re: 11774 - Doom's Day

Yes,you are right!
Now I got it!!!)
by Igor9669
Sun May 02, 2010 9:06 am
Forum: Volume 117 (11700-11799)
Topic: 11774 - Doom's Day
Replies: 10
Views: 3396

Re: 11774 - Doom's Day

Yes, but always WA.....
Here it is:

Code: Select all

DELETED....
}
by Igor9669
Sat May 01, 2010 8:57 pm
Forum: Volume 117 (11700-11799)
Topic: 11774 - Doom's Day
Replies: 10
Views: 3396

11774 - Doom's Day

It's seems that problem is very easy....
if n==m answer is 2
if n and m divisible by 2 answer is (n+m)/2
else answer is (n+m)

please correct me if I'am not right!
by Igor9669
Fri Jan 29, 2010 3:06 pm
Forum: Volume 117 (11700-11799)
Topic: 11770 - Lighting Away
Replies: 27
Views: 8718

Re: WA in problem 11770

in scc you need a reversed graph,but here you dont't need it!
by Igor9669
Sun Jan 24, 2010 12:23 pm
Forum: Volume 117 (11700-11799)
Topic: 11770 - Lighting Away
Replies: 27
Views: 8718

Re: WA in problem 11770

It is like scc!
Make a topologic order and then dfs!
by Igor9669
Sun Nov 08, 2009 12:23 pm
Forum: Volume 102 (10200-10299)
Topic: 10245 - The Closest Pair Problem
Replies: 92
Views: 11555

Re: 10245 Closest Pair

I got a lot of Wa,while compare a square distance, when I change to normal distance(sqrt) I got Ac!
And change this:
if(ans - 10000 >= 1e-10) to
if(ans <10000.0 && fabs(ans-10000.0)<1e-10)

Go to advanced search