Search found 5 matches
Search found 5 matches • Page 1 of 1
- Sun Nov 01, 2015 5:43 am
- Forum: Volume 119 (11900-11999)
- Topic: 11902 - Dominator
- Replies: 20
- Views: 9152
First of all. Rund DFS from node 0 this will give you all the nodes reachables from 0 then consider n disctinct graph's let the graph n_i be the same graph g but without the node i run DFS from 0 in those new graphs If node J were reachable from 0 in the original graph and were NOT reachable in the ...
Just use 2 pointers instead a map. Suppose we have 2 arrays sorted a1 a2 ... an-1 b1 b2 ... bm-1 start with ans=0 and pa=0 and pb=0 the indexes if( a[pa] == b[pb] ) ans++ then you just advance the pointer in the array which has the least number (if they are equal no matter which you choose) repeat w...
- Wed May 06, 2015 1:14 am
- Forum: Volume 112 (11200-11299)
- Topic: 11226 - Reaching the fix-point.
- Replies: 23
- Views: 10247
I got AC in 0.355s Without using shieve. Fisrt- Found a way of factoring a number, I do the TRIAL DIVISION, (just like factoring by hand) anyway. I think that if you could do it in less time, would be great. Given the factoring, computing alpha(n) is easy. (I did it in the same function) Second, Mem...
- Fri Apr 03, 2015 2:44 am
- Forum: Volume 100 (10000-10099)
- Topic: 10075 - Airlines
- Replies: 9
- Views: 4873
Yes, you need to round the distance BEFORE sum them. In other words, when you compute the distance between city A and B, store it as the nearest integer. Then apply the algorithm you want- I used C++11 and Floyd I got AC thanks to this forum :) Also, I applied the formula that comes directly from li...