|
|
вернуться в форумBefor using bfs... Послано NUUZ_1 31 окт 2012 13:27 How can I quickly build adjacency matrix befor using bfs for this problem. I have TLE#6,#10,#12 for this problem. Any algorithm please! Re: Befor using bfs... Adjancency matrix will require 10000^2 elements. It's too many, u won't fit in memory limit. Use adjancency list instead. For example, if you use C++, you can represent it as an array of vectors, where the vector at index i contains numbers of vertices that adjanced to the vertex with number i. for (int i=0; i<N; i++) { int a, b; cin >> a >> b; vect[a].push_back(b); vect[b].push_back(a); } Re: Befor using bfs... ok, there are vectors. but how insert this vectors to the Deikstra algorithm? |
|
|