<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2052758358902108656</id><updated>2026-02-17T14:59:04.878+06:00</updated><category term="Programming"/><category term="Subset"/><category term="iOS"/><category term="Facebook"/><category term="LinkList"/><category term="Xcode"/><category term="iPhone"/><category term="iTunes"/><title type='text'>Saiful&#39;s World</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>121</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-2249931071417257172</id><published>2013-01-23T02:17:00.000+06:00</published><updated>2013-01-23T02:17:35.976+06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook"/><category scheme="http://www.blogger.com/atom/ns#" term="LinkList"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Write a program that reverses alternate elements in a given linked list input: a-&gt;b-&gt;c-&gt;d-&gt;e, output should be b-&gt;a-&gt;d-&gt;c-&gt;e</title><content type='html'>&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;Node reverseAlterante ( Node head) {&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;if ( head == null || head.next == null )&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;        return head;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;Node r = reverseAlternate(head.next.next);&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;Node t = head.next ;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;t.next = head;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;head.next = r;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;return t ;&lt;/span&gt;&lt;br style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot; /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: monospace, sans-serif; font-size: 14px; line-height: 17px; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/2249931071417257172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2013/01/write-program-that-reverses-alternate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2249931071417257172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2249931071417257172'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2013/01/write-program-that-reverses-alternate.html' title='Write a program that reverses alternate elements in a given linked list input: a-&gt;b-&gt;c-&gt;d-&gt;e, output should be b-&gt;a-&gt;d-&gt;c-&gt;e'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.477432 90.084419500000024 23.942410000000002 90.729866500000014</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-4056995054428485310</id><published>2013-01-21T00:20:00.001+06:00</published><updated>2013-01-21T00:20:33.356+06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Subset"/><title type='text'>Printing all possible subsets using BitMask</title><content type='html'>#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
void PrintAllSubset(int n)&lt;br /&gt;
{&lt;br /&gt;
int mask,pos,i,j,noOfSubSet = 1&amp;lt;&amp;lt;n; // subset size 2^n subsets&lt;br /&gt;
for(i=1;i&amp;lt;noOfSubSet;i++)&lt;br /&gt;
&amp;nbsp;{&lt;br /&gt;
for(j=0;j&amp;lt;n;j++)&lt;br /&gt;
if((i&amp;amp;(1&amp;lt;&amp;lt;j)) &amp;gt; 0)&lt;br /&gt;
printf(&quot;%d &quot;,j+1);&lt;br /&gt;
printf(&quot;\n&quot;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
int n;&lt;br /&gt;
while(scanf(&quot;%d&quot;,&amp;amp;n) == 1)&lt;br /&gt;
{&lt;br /&gt;
PrintAllSubset(n);&lt;br /&gt;
}&lt;br /&gt;
return 0;&lt;br /&gt;
}
&lt;stdio .h=&quot;.h&quot;&gt;&lt;n 2=&quot;2&quot; for=&quot;for&quot; i=&quot;i&quot; if=&quot;if&quot; j=&quot;j&quot; n=&quot;n&quot; size=&quot;size&quot; subset=&quot;subset&quot; subsets=&quot;subsets&quot;&gt;&amp;nbsp;&lt;/n&gt;&lt;/stdio&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/4056995054428485310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2013/01/printing-all-possible-subsets-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4056995054428485310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4056995054428485310'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2013/01/printing-all-possible-subsets-using.html' title='Printing all possible subsets using BitMask'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.477435 90.084419500000024 23.942407000000003 90.729866500000014</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-885577796985207973</id><published>2012-12-11T21:06:00.000+06:00</published><updated>2012-12-11T21:06:33.943+06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Subset"/><title type='text'>Write a function to print all subsets of a certain size of the numbers from 1 to n</title><content type='html'>&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
const int MAX = 1000;&lt;br /&gt;
int a[MAX];&lt;br /&gt;
bool b[MAX];&lt;br /&gt;
void f1(int n, int k, int indexn, int indexk){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i, j;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i = indexn; i &amp;lt;= n - k + indexk; i++){&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(!b[i]) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;b[i] = true;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;a[indexk] = i;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(indexk == k) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;for(j = 1; j &amp;lt;= k; j++) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;printf(&quot;%d &quot;, a[j]);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;printf(&quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;} else {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;f1(n, k, indexn + 1, indexk + 1);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;b[i] = false;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
void f(int n, int k) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i = 1; i &amp;lt;= n; ++i) {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;a[i] = i;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;b[i] = false;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;f1(n, k, 1, 1);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int n,k;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while(scanf(&quot;%d %d&quot;,&amp;amp;n,&amp;amp;k) == 2)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; f(n,k);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/885577796985207973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/12/write-function-to-print-all-subsets-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/885577796985207973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/885577796985207973'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/12/write-function-to-print-all-subsets-of.html' title='Write a function to print all subsets of a certain size of the numbers from 1 to n'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-525550348815623944</id><published>2012-11-23T10:24:00.000+06:00</published><updated>2012-11-23T10:24:47.321+06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="iPhone"/><category scheme="http://www.blogger.com/atom/ns#" term="iTunes"/><title type='text'>Unable to establish a secure connection to iTunes/iPhone</title><content type='html'>&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;&lt;b&gt;&lt;i&gt;&quot;Could not establish a secure connection to the device.&quot;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;Here&#39;s what you have to do. You need a backup of your old Mac prior to upgrading, or prior to wiping and reinstalling.&lt;/span&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;You need to open Console on your new mac, and see the error message when you plug your phone into itunes and get that error, this will show up in your console:&lt;/span&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;8/13/12 1:21:04.537 PM iTunes[491]: AMDeviceValidatePairing (thread 0x11c313000): Could not load pairing record /var/db/lockdown//&amp;lt;device id&amp;gt;.plist&lt;/span&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;br style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot; /&gt;&lt;span style=&quot;background-color: #fafafa; font-family: verdana, geneva, lucida, &#39;lucida grande&#39;, arial, helvetica, sans-serif; font-size: 13px;&quot;&gt;Then you need to go to your time machine backup and navigate to that same folder, and find the missing file. Copy that file back to your new machine into the /var/db/lockdown and you will magically be able to access your device again.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/525550348815623944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/11/unable-to-establish-secure-connection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/525550348815623944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/525550348815623944'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/11/unable-to-establish-secure-connection.html' title='Unable to establish a secure connection to iTunes/iPhone'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-6429827055540833456</id><published>2012-11-13T23:52:00.000+06:00</published><updated>2012-11-13T23:52:44.722+06:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="Xcode"/><title type='text'>Make Xcode(4.x) faster</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How to make &amp;nbsp;xcode faster&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #555555; float: right; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 21px; margin: 2px 0px 2px 5px; padding: 2px 0px; vertical-align: baseline;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 21px; list-style-image: initial; list-style-position: inside; margin: 0px 0px 10px 21px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Buying more memory.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Disable indexing if you are building out huge projects in Xcode. This can&amp;nbsp;&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;halve&lt;/em&gt;&amp;nbsp;Xcode’s memory consumption.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Running Xcode in 32 bit. This is not an option for everyone, because it will exceed 4 GB in larger projects.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Reduce the number of build processes (again).&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Restarting Xcode often (It doesn’t do a very good job cleaning up after itself).&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Use clang as your compiler. Clang instances in general use less memory than Apple’s GCC 4.2.&lt;/li&gt;
&lt;li style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Offload dependent targets which do not change often. Example: You will not need to rebuild third party libraries daily in most cases.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Indexing in xcode&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Xcode 4 has an entirely new mechanism for indexing files in a workspace. An index is created for the entire workspace, so references across projects are resolved.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
The indexer now uses the LLVM compiler 2.0 to parse source files. This results in improved performance and higher accuracy; most importantly, the interpretation of symbols for indexing more closely matches the interpretation of syntax at compile time.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
The index is stored in the Index subdirectory of the workspace’s unique directory in&amp;nbsp;&lt;code style=&quot;border: 0px; font: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;~/Library/Developer/Xcode/DerivedData&lt;/code&gt;. Manage this information (including deleting the index and other derived data of an orphaned project) in the Organizer.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Indexing is done in the background; the Activity View indicates when indexing is being performed. Until the index is ready, some functions that require the index may not be available (for example, Open Quickly); others may have degraded performance (for example, syntax coloring of system symbols). When the index is complete these features become available immediately.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
it seems to be that XCode4 and 4.1 uses crazy amounts of Ram during indexing -&amp;nbsp;&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;like, 5gb or so&lt;/strong&gt;(!), and thus if you’re on a machine with something like 12gb, there’s no problem, but if you’re on a laptop with only 2gb or so, you’ll have some pretty severe paging going on.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How to disable indexing&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Open the&amp;nbsp;&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Terminal&lt;/strong&gt;&amp;nbsp; window , then type the following code in terminal and click enter.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;defaults write com.apple.dt.XCode IDEIndexDisable 1&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now restart your xcode and enjoy better performance.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;How to Enable xcode indexing&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
if you upgraded your machine or you want some other features to be turned on if you need indexing service, &amp;nbsp;please follow the steps below.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Open the&amp;nbsp;&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Terminal&lt;/strong&gt;&amp;nbsp; window , then type the following code in terminal and click enter.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;defaults write com.apple.dt.XCode IDEIndexDisable 0&lt;/em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/em&gt;&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(or)&lt;/em&gt;&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;/em&gt;defaults delete com.apple.dt.XCode IDEIndexDisable&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
While you’re at it, you should delete the key you added as well:&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;em style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;defaults delete com.apple.dt.XCode IDEIndexEnable&lt;/em&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now&amp;nbsp;restart the xcode now you can see the indexing will start from now on wards.&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;border: 0px; font: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Disabling SVN &amp;amp; GIT in xcode&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
disabling SVN and Git plugins of XCode. Simply go to /Developer/Library/Xcode/PrivatePlugins&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Now find IDEGit.ideplugin and IDESubversion.ideplugin&lt;/div&gt;
&lt;div style=&quot;background-color: white; border: 0px; clear: none; color: #555555; font-family: Helvetica, Helvetica, serif; font-size: 14px; font: inherit; line-height: 17px; margin-bottom: 10px; padding: 0px; vertical-align: baseline;&quot;&gt;
Change names of both of above plugins so that xcode will not be able to execute them in future.&amp;nbsp;Now restart your xcode and enjoy better performance.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/6429827055540833456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/11/make-xcode4x-faster.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6429827055540833456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6429827055540833456'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/11/make-xcode4x-faster.html' title='Make Xcode(4.x) faster'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-5871443859726635995</id><published>2012-08-06T17:11:00.004+06:00</published><updated>2012-08-06T17:13:23.861+06:00</updated><title type='text'>Install iOS 6 beta on your devices</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: OpenSans, Verdana, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin-bottom: 20px; padding: 0px; vertical-align: baseline;&quot;&gt;
You&#39;re now ready to start installing betas on your devices. To do this, you&#39;ll need to use the newest version of iTunes which is 10.6.3 or you can do this through the xCode 4.5 developer preview. I recommend that developers use the xCode method while app testers are probably okay using the iTunes method unless the developer would prefer you to use xCode to submit feedback.&lt;/div&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; color: #333333; font-family: MyriadWebProRegular; font-size: 36px; font-weight: normal; line-height: 48px; margin: 48px 0px 20px; padding: 0px; vertical-align: baseline;&quot;&gt;
iTunes method&lt;/h2&gt;
&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: OpenSans, Verdana, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; margin-bottom: 20px; padding: 0px; vertical-align: baseline;&quot;&gt;
This time around there is no beta version of iTunes needed. Just make sure you&#39;re running the current version of iTunes which is 10.6.3. You can download it from Apple&#39;s website.&lt;/div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; color: #333333; font-family: OpenSans, Verdana, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 15px 20px; padding: 0px 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://www.apple.com/itunes/download/&quot; style=&quot;border: 0px; color: #cb2c00; margin: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot;&gt;iTunes 10.6.3 download&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol style=&quot;background-color: white; border: 0px; color: #333333; font-family: OpenSans, Verdana, Helvetica, Arial, sans-serif; font-size: 16px; line-height: 25px; list-style-image: initial; list-style-position: initial; margin: 0.25em 0px 15px 20px; padding: 0px 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;Open iTunes 10.6.3 after you&#39;ve installed it and plug in the device you&#39;d like to install iOS 6 beta to.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;Choose your device from the left navigation pane. You&#39;ll see a&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Restore&lt;/strong&gt;&amp;nbsp;button. Hold down&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Alt+option&lt;/strong&gt;&amp;nbsp;(or&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Ctrl&lt;/strong&gt;&amp;nbsp;for PC users) and click&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Restore&lt;/strong&gt;.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;A file browser window will pop up. Navigate to the iOS 6 beta firmware file you would like to install onto your device.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;iTunes will now begin to update your device to iOS 6 beta. Let it do its thing and you&#39;re pretty much done.&lt;/li&gt;
&lt;h2 style=&quot;border: 0px; font-family: MyriadWebProRegular; font-size: 36px; font-weight: normal; line-height: 48px; margin: 48px 0px 20px; padding: 0px; vertical-align: baseline;&quot;&gt;
Xcode method&lt;/h2&gt;
&lt;ol style=&quot;border: 0px; list-style-image: initial; list-style-position: initial; margin: 0.25em 0px 15px 20px; padding: 0px 0px 0px 20px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;In XCode, under software version, you&#39;ll need to choose&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Other version.&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;Then xCode will ask you to navigate to the .ipsw file that you would like to install (the beta firmware file). I typically save them on my desktop or somewhere in a folder that I can easily find.&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;Select it and click&amp;nbsp;&lt;strong style=&quot;border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;Restore iPhone&lt;/strong&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 5px; padding: 0px; vertical-align: baseline;&quot;&gt;A warning will pop up telling you all data will be erased. Agree and your device will be restored to the beta version. You can then restore from a backup in iTunes or from iCloud like you normally would.&lt;/li&gt;
&lt;div style=&quot;border: 0px; margin-bottom: 20px; padding: 0px; vertical-align: baseline;&quot;&gt;
Either update method will get you onto the beta. It&#39;s up to you to decide what method is most appropriate for your situation.&lt;br /&gt;
&lt;br /&gt;
For more &lt;a href=&quot;http://www.imore.com/install-ios-6-beta-xcode-itunes&quot;&gt;Check this&lt;/a&gt;.&lt;span id=&quot;goog_173780738&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_173780739&quot;&gt;&lt;/span&gt;&lt;a href=&quot;http://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/ol&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/5871443859726635995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/08/install-ios-6-beta-on-your-devices.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5871443859726635995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5871443859726635995'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/08/install-ios-6-beta-on-your-devices.html' title='Install iOS 6 beta on your devices'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-2880528478350956822</id><published>2012-08-06T16:54:00.002+06:00</published><updated>2012-08-06T16:54:41.165+06:00</updated><title type='text'>Downgrade iOS 6 Beta to iOS 5.1.1</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #303030; font-family: &#39;Helvetica Neue&#39;, Verdana, Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 22.266666412353516px; margin-bottom: 10px; padding: 0px;&quot;&gt;
If you went ahead and&amp;nbsp;&lt;a href=&quot;http://osxdaily.com/2012/06/16/install-run-ios-6-beta-without-udid-activation-or-a-developer-account/&quot; style=&quot;background-color: inherit; color: #2266bb; font-weight: bold;&quot;&gt;installed iOS 6 beta&lt;/a&gt;&amp;nbsp;and determined the buggy nature of the first developer release isn’t for you, it’s time to downgrade. Most developers should know how to do this already, but if not this process is easy and you’ll be back to running iOS 5.1.1 in no time at all.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #303030; font-family: &#39;Helvetica Neue&#39;, Verdana, Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 22.266666412353516px; margin-bottom: 10px; padding: 0px;&quot;&gt;
Downgrading is identical on an iPhone, iPad, or iPod touch.&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #303030; font-family: &#39;Helvetica Neue&#39;, Verdana, Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 22.266666412353516px; margin: 0px 0px 16px 20px; padding: 0px;&quot;&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;Turn the device off, connect it to the computer via USB, and launch iTunes&lt;/li&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;Place the iOS device into&amp;nbsp;&lt;a href=&quot;http://osxdaily.com/2010/06/24/iphone-dfu-mode-explained-and-how-to-enter-dfu-mode-on-your-iphone/&quot; style=&quot;background-color: inherit; color: #2266bb; font-weight: bold;&quot;&gt;DFU mode&lt;/a&gt;: with the device off, hold down the Power and Home buttons together for 10 seconds then release the power button, continue holding Home button until iTunes notifies you of a device in recovery mode being detected. The devices screen should stay black as if turned off.&lt;/li&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;Restore within iTunes through either method a or b:&lt;/li&gt;
&lt;ul style=&quot;margin: 0px 0px 16px 20px; padding: 0px;&quot;&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;a: Restore from the iOS 5.1.1 backup you made prior to installing iOS 6 beta&lt;/li&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;b: Restore to&amp;nbsp;&lt;a href=&quot;http://osxdaily.com/2012/05/07/ios-5-1-1-download-links/&quot; style=&quot;background-color: inherit; color: #2266bb; font-weight: bold;&quot;&gt;iOS 5.1.1 IPSW&lt;/a&gt;&amp;nbsp;by Option-Clicking the “Restore” button, and then restore from iCloud backup when finished&lt;/li&gt;
&lt;/ul&gt;
&lt;li style=&quot;padding: 0px;&quot;&gt;Let iTunes restore back to iOS 5.1.1, the device will reboot when finished&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #303030; font-family: &#39;Helvetica Neue&#39;, Verdana, Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; line-height: 22.266666412353516px; margin-bottom: 10px; padding: 0px;&quot;&gt;
Typically you can’t downgrade iOS versions so easily, but because Apple is still signing iOS 5.1.1 this allows downgrading to commence with minimal effort.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/2880528478350956822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/08/downgrade-ios-6-beta-to-ios-511.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2880528478350956822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2880528478350956822'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/08/downgrade-ios-6-beta-to-ios-511.html' title='Downgrade iOS 6 Beta to iOS 5.1.1'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-3021063739850967479</id><published>2012-08-05T23:14:00.001+06:00</published><updated>2012-08-05T23:14:59.823+06:00</updated><title type='text'>How to run multiple skype account at the same time in one computer</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;To use more than one Skype account on the same computer at the same time you need to start a new instance of Skype.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; left: 20px; line-height: 21px; list-style-image: initial; list-style-position: outside; margin: 0px 20px 10px 0px; padding: 0px; position: relative;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;From the Windows taskbar, click&amp;nbsp;&lt;strong&gt;Start&lt;/strong&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;strong&gt;Run&lt;/strong&gt;&amp;nbsp;(or press the&amp;nbsp;&lt;strong&gt;Windows&lt;/strong&gt;&amp;nbsp;and&amp;nbsp;&lt;strong&gt;R&lt;/strong&gt;&amp;nbsp;keys on your keyboard at the same time)&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;In the Run window, enter the following command (include the quotes) and press&amp;nbsp;&lt;strong&gt;OK&lt;/strong&gt;:&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;&lt;em&gt;&lt;em&gt;&quot;C:\Program Files\Skype\Phone\Skype.exe&quot; /secondary&amp;nbsp;&lt;/em&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;If you get an error message, copy and paste the exact command from this&amp;nbsp;page and try again.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;Be aware that if you have changed the installation path for Skype then you will need to enter the correct path for the Skype.exe file.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; padding: 0px;&quot;&gt;
&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;If this solution fails, you can&amp;nbsp;try another option:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;background-color: white; color: #555555; font-family: Helvetica, Arial, sans-serif; font-size: 14px; left: 20px; line-height: 21px; list-style-image: initial; list-style-position: outside; margin: 0px 20px 10px 0px; padding: 0px; position: relative;&quot;&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;Find the Skype executable file (Skype.exe)&amp;nbsp;in:&amp;nbsp;&lt;em&gt;C:\Program Files\Skype\Phone\&amp;nbsp;&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;Right click on it and&amp;nbsp;select&amp;nbsp;&lt;strong&gt;Send to&lt;/strong&gt;&amp;nbsp;&amp;gt;&amp;nbsp;&lt;strong&gt;Desktop (create shortcut)&lt;/strong&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;Locate the shortcut on the desktop, then right-click on it and&amp;nbsp;select&amp;nbsp;&lt;strong&gt;Properties&lt;/strong&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;In the&amp;nbsp;&lt;strong&gt;Target&lt;/strong&gt;&amp;nbsp;field, add:&amp;nbsp;&lt;em&gt;/secondary&lt;/em&gt;.&amp;nbsp;The Target field should now be&amp;nbsp;&lt;em&gt;&quot;C:\Program Files\Skype\Phone\Skype.exe&quot; /secondary&lt;/em&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;color: green; line-height: normal;&quot;&gt;Click&amp;nbsp;&lt;strong&gt;OK&lt;/strong&gt;. You can now start a new instance of Skype every time you double-click&amp;nbsp;the new shortcut.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/3021063739850967479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/08/how-to-run-multiple-skype-account-at.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3021063739850967479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3021063739850967479'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/08/how-to-run-multiple-skype-account-at.html' title='How to run multiple skype account at the same time in one computer'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143</georss:point><georss:box>23.4773095 90.091286000000011 23.942532500000002 90.723</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-6337414439736733428</id><published>2012-03-25T20:04:00.000+06:00</published><updated>2012-03-25T20:04:50.174+06:00</updated><title type='text'>PROGRAM TO FIND SQUARE ROOT OF A NUMBER - C CODE</title><content type='html'>&lt;blockquote class=&quot;tr_bq&quot; style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
float SquareRoot(float num);&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; float input, ans;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n Enter The Number : &quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(scanf(&quot;%f&quot;, &amp;amp;input) == 1)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ans = SquareRoot(input);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf(&quot;\n Square Root : %f\n&quot;, ans);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;
}&lt;br /&gt;
float SquareRoot(float num)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(num &amp;gt;= 0)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; float x = num;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i = 0; i &amp;lt; 20; i ++)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = (((x * x) + num) / (2 * x));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return x;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/6337414439736733428/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/03/program-to-find-square-root-of-number-c.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6337414439736733428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6337414439736733428'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/03/program-to-find-square-root-of-number-c.html' title='PROGRAM TO FIND SQUARE ROOT OF A NUMBER - C CODE'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>3</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.590555000000002 90.317364000000026 23.829287 90.496922000000012</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-1741784078525263115</id><published>2012-02-26T04:28:00.000+06:00</published><updated>2012-02-26T04:28:53.278+06:00</updated><title type='text'>Remove Powered by Blogger from your Blogger blog in new Blogger interface</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;To&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;a href=&quot;http://www.sundeepmachado.com/2011/09/remove-powered-by-blogger-from-your.html&quot; style=&quot;text-decoration: none;&quot;&gt;Remove Powered by Blogger from your Blogger blog in new Blogger interface&lt;/a&gt;&amp;nbsp;please visit the following link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;a href=&quot;http://www.sundeepmachado.com/2011/09/remove-powered-by-blogger-from-your.html&quot;&gt;http://www.sundeepmachado.com/2011/09/remove-powered-by-blogger-from-your.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/1741784078525263115/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/remove-powered-by-blogger-from-your.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/1741784078525263115'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/1741784078525263115'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/remove-powered-by-blogger-from-your.html' title='Remove Powered by Blogger from your Blogger blog in new Blogger interface'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>2</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-2498881732008750382</id><published>2012-02-08T00:14:00.000+06:00</published><updated>2012-02-08T00:14:24.512+06:00</updated><title type='text'>Web page Downloader in Java ( Basic URL connection) like facebook</title><content type='html'>/*&lt;br /&gt;
&amp;nbsp;* @(#)DownloadPage.java&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;*&lt;br /&gt;
&amp;nbsp;* @author Md. Saiful Islam&lt;br /&gt;
&amp;nbsp;* @Reg &amp;nbsp; &amp;nbsp;: &amp;nbsp; 2005331074&lt;br /&gt;
&amp;nbsp;* @version 1.00 2010/7/29&lt;br /&gt;
&amp;nbsp;*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import java.net.InetAddress;&lt;br /&gt;
import java.net.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.math.*;&lt;br /&gt;
import java.lang.*;&lt;br /&gt;
&lt;br /&gt;
public class DownloadPage&lt;br /&gt;
{ &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public DownloadPage() { }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public static void main(String[] args) &amp;nbsp;throws &amp;nbsp;IOException&lt;br /&gt;
&amp;nbsp; &amp;nbsp; { &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;URL url;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;InputStream is = null;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;DataInputStream dis;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String Link,line,PageName;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Link = &quot;http://www.facebook.com/&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;FileOutputStream fileOutput;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PageName = &quot;Download.html&quot;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;File file = new File(PageName);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;file.createNewFile();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;fileOutput = new FileOutputStream(file);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;url = new URL(Link);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;is = url.openStream();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;dis = new DataInputStream(new BufferedInputStream(is));&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;while( ( line = dis.readLine() ) != null )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(line);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fileOutput.write(line.getBytes());&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;catch ( MalformedURLException waste )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;waste.printStackTrace();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;catch ( IOException input )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;input.printStackTrace();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;finally&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;try&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;is.close();&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; catch (IOException ioe)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} // End of finally&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; } // End of main class&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;br /&gt;
} // End of DownloadPage class&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/2498881732008750382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/web-page-downloader-in-java-basic-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2498881732008750382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/2498881732008750382'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/web-page-downloader-in-java-basic-url.html' title='Web page Downloader in Java ( Basic URL connection) like facebook'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-6056554821689756405</id><published>2012-02-08T00:09:00.000+06:00</published><updated>2012-02-08T00:09:09.857+06:00</updated><title type='text'>Topological Sort With Back Edge Or Cycle( UVA - 11686)</title><content type='html'>&lt;span style=&quot;color: purple;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Topological Sort With Back Edge Or Cycle&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#define mm 100000&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;long ff,k,Node,Edge,a,b,x,aa[mm],flag[mm], tag;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;vector&amp;lt; long &amp;gt;adjlist[mm];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;void dfs_visit(long x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; long i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; flag[x] = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; for(i = 0; i &amp;lt; adjlist[x].size(); i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ff=adjlist[x].at(i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(flag[ff] == 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dfs_visit(adjlist[x][i]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if(flag[ff] == 1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tag = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; aa[k++] = x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; flag[x] = 2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; long i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; while(scanf(&quot;%ld %ld&quot;,&amp;amp;Node,&amp;amp;Edge)==2 &amp;amp;&amp;amp; (Node || Edge))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag[i] =0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adjlist[i].clear();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%ld %ld&quot;,&amp;amp;a,&amp;amp;b);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adjlist[a-1].push_back(b-1);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tag = 0; k=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i = 0;i &amp;lt; Node; i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(flag[i] == 0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dfs_visit(i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(tag == 1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;IMPOSSIBLE\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=k-1;i&amp;gt;=0;i--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%ld\n&quot;,aa[i]+1);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/6056554821689756405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/topological-sort-with-back-edge-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6056554821689756405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6056554821689756405'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/topological-sort-with-back-edge-or.html' title='Topological Sort With Back Edge Or Cycle( UVA - 11686)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-7144714739567372576</id><published>2012-02-08T00:08:00.000+06:00</published><updated>2012-02-08T00:08:14.579+06:00</updated><title type='text'>Topological Sort (10305 - Ordering Tasks)</title><content type='html'>&lt;span style=&quot;color: blue;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Topological Sort&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int Node,Edge,adjlist[102][102],a,b,start,i,x,front;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;bool flag[110];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void dfs_visit(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if( !flag[x])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;flag[x] = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i = 1;i &amp;lt;= adjlist[x][0];i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;dfs_visit(adjlist[x][i]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;start++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(start != Node) printf(&quot;%d &quot;,x);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else printf(&quot;%d&quot;,x);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot;%d%d&quot;,&amp;amp;Node,&amp;amp;Edge)==2 &amp;amp;&amp;amp; (Node || Edge))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d %d&quot;,&amp;amp;a,&amp;amp;b);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;adjlist[b][++adjlist[b][0]] = a;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;start = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(front = 1;front &amp;lt;= Node; front++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;dfs_visit(front);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;adjlist[i][0] = flag[i] = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/7144714739567372576/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/topological-sort-10305-ordering-tasks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7144714739567372576'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7144714739567372576'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/topological-sort-10305-ordering-tasks.html' title='Topological Sort (10305 - Ordering Tasks)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-7106923947988804859</id><published>2012-02-08T00:07:00.002+06:00</published><updated>2012-02-08T00:07:14.140+06:00</updated><title type='text'>Strongly Connected Component</title><content type='html'>&lt;span style=&quot;color: #990000;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; Strongly Connected Component&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;#include&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;#include&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;#define sz 10001&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;vector&amp;lt;int&amp;gt;adj[sz];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;int Node,Edge,u,v,array[sz],top,r;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;bool Flag[sz];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;void DFS(int u,bool s)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; if(Flag[u] == s) return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; Flag[u]= s;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; for(int i=0;i&amp;lt;adj[u].size();i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DFS(adj[u][i],s);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; if(s) array[top--]=u;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; int i,j,test,cnt,kase=1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;test);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; while(test--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d %d&quot;,&amp;amp;Node,&amp;amp;Edge);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d %d&quot;,&amp;amp;u,&amp;amp;v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adj[u].push_back(v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; top=Node; cnt=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!Flag[i])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DFS(i,true);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if( Flag[ array[i] ] )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DFS( array[i] , false );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cnt++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; adj[ array[i] ].clear();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Case %d: %d\n&quot;,kase++,cnt);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;=Node;i++)Flag[i] = false;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;5 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;1 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;1 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;3 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;5 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;4 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;1 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;1 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;4 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;4 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;3 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;1 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;2 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Case 1: 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Case 2: 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;Case 3: 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #990000;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/7106923947988804859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/strongly-connected-component.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7106923947988804859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7106923947988804859'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/strongly-connected-component.html' title='Strongly Connected Component'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-4319844610880647277</id><published>2012-02-08T00:06:00.002+06:00</published><updated>2012-02-08T00:06:34.939+06:00</updated><title type='text'>Second Best MST (UVA 10462 - Is there any second way)</title><content type='html'>&lt;span style=&quot;color: purple;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Second Best MST (UVA 10462 - Is there any second way)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#define INF 99999999&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;struct S&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int u,v,cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;S a[203];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Set[203],Rank[203],store[203];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Node,Edge;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;void make_set(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Set[x] = x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Rank[x] = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int find_set(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(x != Set[x])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = find_set(Set[x]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return Set[x];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;void Union(int x,int y)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(Rank[x] &amp;gt; Rank[y])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[y] = x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(Rank[x] == Rank[y])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Rank[y]++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int comp_fun(const void *m,const void *n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;S *x,*y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;x=(S*)m;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;y=(S*)n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return ( x-&amp;gt;cost - y-&amp;gt;cost );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,u_set,v_set,sum,set,test,ans,k,min,cnt,y,kase=1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;test);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(test--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d %d&quot;,&amp;amp;Node,&amp;amp;Edge);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;set &amp;nbsp;= 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;make_set(i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ans = -1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;scanf(&quot;%d %d %d&quot;,&amp;amp;a[i].u,&amp;amp;a[i].v,&amp;amp;a[i].cost);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;qsort(a,Edge,sizeof(S),comp_fun);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sum = k = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0; i&amp;lt;Edge ;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;u_set=find_set(a[i].u);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;v_set=find_set(a[i].v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if( u_set!=v_set )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;store[k++]=i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum += a[i].cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Union(u_set,v_set);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// second best MST start here&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//if(k &amp;gt;= Node-1)ans = sum; // First MST Cost&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;min = INF;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(y=0;y&amp;lt;k;y++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;sum = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(i=0;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;make_set(i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(i=cnt=0;i&amp;lt;Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(store[y] != i)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;u_set=find_set(a[i].u);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;v_set=find_set(a[i].v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;if( u_set!=v_set )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;cnt++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;sum += a[i].cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;Union(u_set,v_set);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(cnt &amp;gt;= Node-1 &amp;amp;&amp;amp; sum &amp;lt; min) min = sum;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(ans == -1)printf(&quot;Case #%d : No way\n&quot;,kase++);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else if(min == INF)printf(&quot;Case #%d : No second way\n&quot;,kase++);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else printf(&quot;Case #%d : %d\n&quot;,kase++,min);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;3 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 4 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;3 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 4 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;3 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 4 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 5 6&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #1 : No second way&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #2 : No way&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #3 : 21 // second best cost&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #4 : No second way&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/4319844610880647277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/second-best-mst-uva-10462-is-there-any.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4319844610880647277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4319844610880647277'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/second-best-mst-uva-10462-is-there-any.html' title='Second Best MST (UVA 10462 - Is there any second way)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-3027111210803539857</id><published>2012-02-08T00:05:00.003+06:00</published><updated>2012-02-08T00:05:58.513+06:00</updated><title type='text'>Minimum Spanning Tree (Prims Algorithm)</title><content type='html'>&lt;span style=&quot;color: purple;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Minimum Spanning Tree (Prims Algorithm)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;vector&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;list&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;map&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;set&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;deque&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;stack&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;bitset&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;algorithm&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;functional&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;numeric&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;utility&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;sstream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;iomanip&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;cstdio&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;cmath&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;cstdlib&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;ctime&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include &amp;lt;queue&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#define SIZE 10000&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;struct pq&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int cost,node;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;bool operator&amp;lt;(const pq &amp;amp;b)const&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return cost&amp;gt;b.cost; &amp;nbsp; &amp;nbsp;// Min Priority Queue&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Prims(vector&amp;lt;pq&amp;gt;adj[],int source,int nodes)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;priority_queue&amp;lt;pq&amp;gt;Q;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;vector&amp;lt;int&amp;gt;color(nodes);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;pq U,V;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,sum;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;V.node=source;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sum=V.cost=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Q.push(V);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(!Q.empty())&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;U=Q.top();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(color[U.node]==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum+=U.cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;color[U.node]=1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Q.pop();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;adj[U.node].size();i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(color[ adj[U.node][i].node]==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;V.node=adj[U.node][i].node;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;V.cost=adj[U.node][i].cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Q.push(V);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return sum;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int nodes,edges,i,u,v,cost,source,val;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;pq V;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;vector&amp;lt;int&amp;gt;dist;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;vector&amp;lt;pq&amp;gt;adj[SIZE];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot;%d %d&quot;,&amp;amp;nodes,&amp;amp;edges)==2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;nodes;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;adj[i].clear(); //clear adj vector&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;edges;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d %d %d&quot;,&amp;amp;u,&amp;amp;v,&amp;amp;cost);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;V.cost=cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;V.node=v;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;adj[u].push_back(V);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;V.node=u;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;//For Bidirectional Edges&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;adj[v].push_back(V);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;val=Prims(adj,0,nodes);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%d\n&quot;,val);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 5 7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 0 1 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 0 2 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 1 2 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 1 4 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 2 4 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 2 3 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 3 4 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/3027111210803539857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/minimum-spanning-tree-prims-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3027111210803539857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3027111210803539857'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/minimum-spanning-tree-prims-algorithm.html' title='Minimum Spanning Tree (Prims Algorithm)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-8082441181190615343</id><published>2012-02-08T00:05:00.000+06:00</published><updated>2012-02-08T00:05:21.214+06:00</updated><title type='text'>Minimum spanning tree Kurskal Using MAP + String</title><content type='html'>&lt;span style=&quot;color: blue;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; MST - Kurskal Using MAP + String&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; UVA - 11710 Expensive Subway&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;map&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;string&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;string.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;algorithm&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;using namespace std;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int cnt,i,node,edge,sum,u,v,cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int rank[410],parent[410],array[79810][3];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;char str[15];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;map&amp;lt;string,int&amp;gt;flag;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int cmp(const void *a,const void *b)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;int *x = (int *) a;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;int *y = (int *) b;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;return *x - *y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int Find_Set(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(x != parent[x] )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;parent[x]=Find_Set(parent[x]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; return parent[x];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void Link(int x,int y)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(rank[x]&amp;gt;rank[y]) parent[y]=x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;parent[x]=y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(rank[x]==rank[y]) &amp;nbsp; &amp;nbsp;rank[y]=rank[y]+1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; while(scanf(&quot;%d %d&quot;,&amp;amp;node,&amp;amp;edge)==2 &amp;amp;&amp;amp; (node || edge))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag[str]=i+1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; parent[i]=i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rank[i]=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum = cnt = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; u = flag[str]-1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v = flag[str]-1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;cost);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array[i][0]=cost;array[i][1] = u; array[i][2] = v;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qsort(array,edge,sizeof(array[0]),cmp);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; u = array[i][1];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v = array[i][2];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cost = array[i][0];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; u = Find_Set(u);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v = Find_Set(v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(u!=v)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Link(u,v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cnt++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum+=cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%s&quot;,str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(cnt!=node-1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;Impossible\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else printf(&quot;%d\n&quot;,sum);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag.clear();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;3 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Picadilly&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Victoria&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Queensway&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Picadilly Victoria 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Queensway Victoria 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Queensway Picadilly 20&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Picadilly&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;4 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Picadilly&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Victoria&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Queensway&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Temple&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Picadilly Victoria 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Temple Queensway 100&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Temple&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;12&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Impossible&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/8082441181190615343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/minimum-spanning-tree-kurskal-using-map.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/8082441181190615343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/8082441181190615343'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/minimum-spanning-tree-kurskal-using-map.html' title='Minimum spanning tree Kurskal Using MAP + String'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-5735498235837881178</id><published>2012-02-08T00:03:00.000+06:00</published><updated>2012-02-08T00:03:31.169+06:00</updated><title type='text'>Normal Kurskal algorithm (Cordinate Given)</title><content type='html'>/***&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Normal Kurskal (Cordinate Given)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;br /&gt;
***/&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include&amp;lt;math.h&amp;gt;&lt;br /&gt;
#define Node_num 10004&lt;br /&gt;
&lt;br /&gt;
struct S&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int u,v,cost;&lt;br /&gt;
};&lt;br /&gt;
S a[Node_num];&lt;br /&gt;
&lt;br /&gt;
int Set[Node_num],Rank[Node_num];&lt;br /&gt;
int Node,Edge;&lt;br /&gt;
double x[10003],y[10003];&lt;br /&gt;
&lt;br /&gt;
void make_set(int x)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Set[x] = x;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Rank[x] = 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int find_set(int x)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(x != Set[x])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = find_set(Set[x]);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return Set[x];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void Union(int x,int y)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(Rank[x] &amp;gt; Rank[y])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[y] = x;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = y;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(Rank[x] == Rank[y])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Rank[y]++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int comp_fun(const void *m,const void *n)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;S *x,*y;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;x=(S*)m;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;y=(S*)n;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return ( x-&amp;gt;cost - y-&amp;gt;cost );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int &amp;nbsp;test,n,k,i,j,u_set,v_set,flag;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;double sum,t1,t2;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;test);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(test--)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;flag = 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%lf %lf&quot;,&amp;amp;x[i],&amp;amp;y[i]);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;k=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;n-1;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=i+1;j&amp;lt;n;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;a[k].u=i+1,a[k].v=j+1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;t1=x[i]-x[j],t2=y[i]-y[j];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;a[k].cost = t1*t1 + t2*t2;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;k++;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;qsort(a,k,sizeof(S),comp_fun);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;=n;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;make_set(i);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sum = 0.0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0; i&amp;lt;k ;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;u_set=find_set(a[i].u);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;v_set=find_set(a[i].v);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(u_set!=v_set)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;sum += sqrt(a[i].cost);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Union(u_set,v_set);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;flag = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%.2lf\n&quot;,sum);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(test)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
Input:&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
3&lt;br /&gt;
1.0 1.0&lt;br /&gt;
2.0 2.0&lt;br /&gt;
2.0 4.0&lt;br /&gt;
Output:&lt;br /&gt;
3.41&lt;br /&gt;
*/&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/5735498235837881178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/normal-kurskal-algorithm-cordinate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5735498235837881178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5735498235837881178'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/normal-kurskal-algorithm-cordinate.html' title='Normal Kurskal algorithm (Cordinate Given)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-6692493096284464615</id><published>2012-02-07T23:49:00.003+06:00</published><updated>2012-02-07T23:49:47.088+06:00</updated><title type='text'>MST - Kurskal Algorithm</title><content type='html'>&lt;span style=&quot;color: blue;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; MST - Kurskal Algorithm&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;struct S&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int u,v,cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;S a[10002];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int Set[1002],Rank[1002];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int Node,Edge;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void make_set(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Set[x] = x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Rank[x] = 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int find_set(int x)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(x != Set[x])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = find_set(Set[x]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return Set[x];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void Union(int x,int y)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(Rank[x] &amp;gt; Rank[y])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[y] = x;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Set[x] = y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(Rank[x] == Rank[y])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Rank[y]++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int comp_fun(const void *m,const void *n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;S *x,*y;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;x=(S*)m;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;y=(S*)n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return ( y-&amp;gt;cost - x-&amp;gt;cost );&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,taken,u_set,v_set,test,kase=1,max;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;test);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(test--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d %d&quot;,&amp;amp;Node,&amp;amp;Edge);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;scanf(&quot;%d %d %d&quot;,&amp;amp;a[i].u,&amp;amp;a[i].v,&amp;amp;a[i].cost);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;qsort(a,Edge,sizeof(S),comp_fun);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;make_set(i);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;taken=1;max = 99999999;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0; taken&amp;lt;Node ;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;u_set=find_set(a[i].u);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;v_set=find_set(a[i].v);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if( u_set!=v_set )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;++taken;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(a[i].cost &amp;lt;= max)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;max = a[i].cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Union(u_set,v_set);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Case #%d: %d\n&quot;,kase++,max);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;2 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 1 10&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 1 20&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 0 30&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;4 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 1 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;3 1 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;1 2 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;2 3 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;0 2 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Case #1: 20&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;Case #2: 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/6692493096284464615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/mst-kurskal-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6692493096284464615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/6692493096284464615'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/mst-kurskal-algorithm.html' title='MST - Kurskal Algorithm'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-7938618855553376131</id><published>2012-02-07T23:49:00.000+06:00</published><updated>2012-02-07T23:49:05.866+06:00</updated><title type='text'>DisJoint Set Operation</title><content type='html'>/***&lt;br /&gt;
&amp;nbsp; &amp;nbsp; DisJoint Set Operation&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;br /&gt;
***/&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int node,rank[50010],parent[50010],i,sum,edge,a,b,cnt=0,ans[50011],mx,test,temp;&lt;br /&gt;
&lt;br /&gt;
int Find_Set(int x)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(x != parent[x] )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;parent[x]=Find_Set(parent[x]);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return parent[x];&lt;br /&gt;
}&lt;br /&gt;
void Link(int x,int y)&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(rank[x]&amp;gt;rank[y])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; parent[y]=x;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ans[x]+=ans[y];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;parent[x]=y;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ans[y] += ans[x];&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(rank[x]==rank[y])&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;rank[y]=rank[y]+1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int set;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;test);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while( test-- )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;set = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;scanf(&quot;%d %d&quot;,&amp;amp;node,&amp;amp;edge);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;=50001;i++)parent[i]=i,rank[i]=0,ans[i]=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;node;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;ans[i]);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;cnt = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for( i=0 ; i&amp;lt;edge ; i++ )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;scanf(&quot;%d %d&quot;,&amp;amp;a,&amp;amp;b);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a = Find_Set(a);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;b = Find_Set(b);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if( a != b )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; &amp;nbsp; &amp;nbsp;Link(a,b);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;node;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(parent[i] == i)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(ans[i]!= 0)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;set = 1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;break;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(set)printf(&quot;IMPOSSIBLE\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;else printf(&quot;POSSIBLE\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
Input:&lt;br /&gt;
2&lt;br /&gt;
5 3&lt;br /&gt;
100&lt;br /&gt;
-75&lt;br /&gt;
-25&lt;br /&gt;
-42&lt;br /&gt;
42&lt;br /&gt;
0 1&lt;br /&gt;
1 2&lt;br /&gt;
3 4&lt;br /&gt;
4 2&lt;br /&gt;
15&lt;br /&gt;
20&lt;br /&gt;
-10&lt;br /&gt;
-25&lt;br /&gt;
0 2&lt;br /&gt;
1 3&lt;br /&gt;
Sample Output&lt;br /&gt;
POSSIBLE&lt;br /&gt;
IMPOSSIBLE&lt;br /&gt;
*/</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/7938618855553376131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/disjoint-set-operation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7938618855553376131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/7938618855553376131'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/disjoint-set-operation.html' title='DisJoint Set Operation'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-1026941639111182766</id><published>2012-02-07T23:48:00.000+06:00</published><updated>2012-02-07T23:48:24.158+06:00</updated><title type='text'>FloodFill With BFS using Knight moves</title><content type='html'>&lt;span style=&quot;color: purple;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Knight moves Made by&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int boa[10][10],que[65][2],flg,cost[65];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int x[]={-2,-2,-1,1,2,2,1,-1};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int y[]={-1,1,-2,-2,1,-1,2,2};&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Bfs(int c1,int r1,int c2,int r2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(c1==c2&amp;amp;&amp;amp;r1==r2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int h,t,i,c,r,tr,tc;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;h=t=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;que[h][0]=r1,que[h][1]=c1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;boa[r1][c1]=flg;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;cost[h]=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;h++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(t!=h)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;r=que[t][0],c=que[t][1];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;8;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;tr=r+x[i],tc=c+y[i];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(tr&amp;gt;0&amp;amp;&amp;amp;tr&amp;lt;=8&amp;amp;&amp;amp;tc&amp;gt;0&amp;amp;&amp;amp;tc&amp;lt;=8&amp;amp;&amp;amp;boa[tr][tc]!=flg)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;boa[tr][tc]=flg;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;cost[h]=cost[t]+1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(tr==r2&amp;amp;&amp;amp;tc==c2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;return cost[h];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;que[h][0]=tr,que[h][1]=tc;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;h++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;t++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int r1,r2,n;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;char c1,c2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot;%c%d %c%d &quot;,&amp;amp;c1,&amp;amp;r1,&amp;amp;c2,&amp;amp;r2) == 4)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;flg++;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;n=Bfs(c1-&#39;a&#39;+1,r1,c2-&#39;a&#39;+1,r2);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;To get from %c%d to %c%d takes %d knight moves.\n&quot;,c1,r1,c2,r2,n);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;e2 e4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;a1 b2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;b2 c3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;a1 h8&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;a1 h7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;h8 a1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;b1 c3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;f6 f6&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from e2 to e4 takes 2 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from a1 to b2 takes 4 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from b2 to c3 takes 2 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from a1 to h8 takes 6 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from a1 to h7 takes 5 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from h8 to a1 takes 6 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from b1 to c3 takes 1 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;To get from f6 to f6 takes 0 knight moves.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/1026941639111182766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-using-knight-moves.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/1026941639111182766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/1026941639111182766'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-using-knight-moves.html' title='FloodFill With BFS using Knight moves'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-5547393918301075568</id><published>2012-02-07T23:47:00.000+06:00</published><updated>2012-02-07T23:47:12.712+06:00</updated><title type='text'>FloodFill With BFS in 4 direction(657 - The die is cast)</title><content type='html'>#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;algorithm&amp;gt;&lt;br /&gt;
#define sz 11000&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
&lt;br /&gt;
struct st&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int x, y;&lt;br /&gt;
}Q[sz*sz] ;&lt;br /&gt;
&lt;br /&gt;
char mat[60][60];&lt;br /&gt;
int store[sz],res;&lt;br /&gt;
&lt;br /&gt;
void BFS( st s )&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;st u ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int front=0,rear=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i, rr[4]={0,0,1,-1}, cc[4] = {1,-1,0,0};&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;mat[s.x][s.y] = &#39;*&#39; ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Q[rear++] = s ;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while( front!=rear )&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;u = Q[front++] ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;4;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if( mat[u.x+rr[i]][u.y+cc[i]] == &#39;X&#39;) &amp;nbsp; //??&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;mat[u.x+rr[i]][u.y+cc[i]]= &#39;*&#39;;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Q[rear].x = u.x+rr[i] ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Q[rear].y = u.y+cc[i] ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;rear++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
void BFS1( st s )&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; printf(&quot;i = = %d j == %d\n&quot;,s.x,s.y);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;st u ,v;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int front=0,rear=0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i, rr[4]={0,0,1,-1}, cc[4] = {1,-1,0,0};&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;mat[s.x][s.y] = &#39;.&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Q[rear++] = s ;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; while( front!=rear )&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;front = %d %d\n&quot;,front,rear);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; u = Q[front++] ;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;4;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(mat[u.x+rr[i]][u.y+cc[i]] == &#39;X&#39;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; store[res]++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v.x=u.x+rr[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; v.y=u.y+cc[i];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;v = %d %d\n&quot;,v.x,v.y);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BFS(v);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;u = %d %d\n&quot;,u.x,u.y);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mat[u.x+rr[i]][u.y+cc[i]]= &#39;.&#39;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Q[rear].x = u.x+rr[i] ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Q[rear].y = u.y+cc[i] ;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rear++;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;freopen(&quot;657.txt&quot;,&quot;r&quot;,stdin);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int r, c, i, j,kase=1;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;char aa;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;st u ;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot;%d %d &quot;,&amp;amp;c,&amp;amp;r) == 2 &amp;amp;&amp;amp; (r||c))&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;r;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=0;j&amp;lt;c;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;scanf(&quot;%c&quot;,&amp;amp;aa);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;mat[i][j] = aa;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%c&quot;,&amp;amp;aa);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;res = 0 ;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;r;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=0;j&amp;lt;c;j++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if( mat[i][j] != &#39;.&#39;)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;u.x = i ; u.y = j ;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;printf(&quot;i == %d %d \n&quot;,i,j);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;BFS1(u);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;res++;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sort(store,store+res);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Throw %d\n&quot;,kase++);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;res;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(store[i]!=0)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;printf(&quot;%d&quot;,store[i++]);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;break;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(;i&amp;lt;res;i++)&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot; %d&quot;,store[i]);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\n\n&quot;);&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;10100;i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; store[i] = 0;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/5547393918301075568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-in-4-direction657.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5547393918301075568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/5547393918301075568'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-in-4-direction657.html' title='FloodFill With BFS in 4 direction(657 - The die is cast)'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-8221783104063613836</id><published>2012-02-07T23:46:00.000+06:00</published><updated>2012-02-07T23:46:06.707+06:00</updated><title type='text'>FloodFill With BFS in 8 direction</title><content type='html'>&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;/***&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; FloodFill With BFS&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;***/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;#define sz 26&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;struct st&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int x, y;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;}Q[sz*sz] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;int mat[sz][sz], line[sz] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;int front, rear ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;void BFS( st s )&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;st u ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i, rr[8]={0, 0, -1,-1,-1, 1, 1, 1}, cc[8] = {1,-1, 0, -1, 1, -1, 0, 1};&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;mat[s.x][s.y] = 0 ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Q[rear++] = s ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while( front != rear )&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;u = Q[front++] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=0;i&amp;lt;8;i++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if( mat[u.x+rr[i]][u.y+cc[i]] == 1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;mat[u.x+rr[i]][u.y+cc[i]] = 0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Q[rear].x = u.x+rr[i] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Q[rear].y = u.y+cc[i] ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;rear++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;int main()&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int r, c, i, j, res,aa,kase=1;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;st u ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while( scanf(&quot; %d&quot;,&amp;amp;r) == 1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=r;i++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=r;j++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;scanf(&quot; %1d&quot;,&amp;amp;aa);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;mat[i][j] = aa ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;res = 0 ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=r;i++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=r;j++)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if( mat[i][j] == 1)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;res++;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;front = rear = 0 ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;u.x = i ; u.y = j ;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;BFS(u);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Image number %d contains %d war eagles.\n&quot;,kase++,res);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;/*&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Input:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;6&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;100100&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;001010&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;000000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;110000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;111000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;010100&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;8&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;01100101&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;01000001&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;00011000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;00000010&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;11000011&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;10100010&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;10000001&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;01100000&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Output:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Image number 1 contains 3 war eagles.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Image number 2 contains 6 war eagles.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/8221783104063613836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-in-8-direction.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/8221783104063613836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/8221783104063613836'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/floodfill-with-bfs-in-8-direction.html' title='FloodFill With BFS in 8 direction'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>1</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-4089147898744540405</id><published>2012-02-07T23:44:00.002+06:00</published><updated>2012-02-07T23:44:51.745+06:00</updated><title type='text'>Directed path Floyd_Warshall algorithm</title><content type='html'>&lt;span style=&quot;color: blue;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; For Directed path Floyd_Warshall algorithm&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#define NIL 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;#define INF 99999&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int cost[1008][1008],path[109][109];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void init(int n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,j;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=0;i&amp;lt;=n;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(j=0;j&amp;lt;=n;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(i == j)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;cost[i][j] = NIL;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else cost[i][j] = INF;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;path[i][j] = NIL; //to print path&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return ;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void Floyd_Warshall(int n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,j,k;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(k=1;k&amp;lt;=n;k++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=n;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=n;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(cost[i][j] &amp;gt; cost[i][k] + cost[k][j])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;cost[i][j] = cost[i][k] + cost[k][j];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;path[i][j] = path[k][j]; // to print path&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return ;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void print_matrix_path(int n)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,j;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\ndistance matrix:\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=1;i&amp;lt;=n;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(j=1;j&amp;lt;=n;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;%d &quot;,cost[i][j]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;PATH matrix :\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=1;i&amp;lt;=n;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(j=1;j&amp;lt;=n;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;%d &quot;,path[i][j]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void print_path(int s,int e)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(path[s][e]==s)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%d&quot;,path[s][e]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else if(path[s][e]==0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;No path&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//pik=5;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print_path(s,path[s][e]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot; %d&quot;,path[s][e]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,node,edge,s,e,t,a,b,c,j;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot; %d%d&quot;,&amp;amp;node,&amp;amp;edge)==2 &amp;amp;&amp;amp; (node || edge))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;init(node);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d%d%d&quot;,&amp;amp;a,&amp;amp;b,&amp;amp;c);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;cost[a][b] = c;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;//for print path &amp;amp;&amp;amp; cycle&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=node;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(cost[i][j]!=INF &amp;nbsp;&amp;amp;&amp;amp; i!=j)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;path[i][j]=i;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Floyd_Warshall(node);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print_matrix_path(node);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot; %d&quot;,&amp;amp;t);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(t--)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot; %d %d&quot;,&amp;amp;s,&amp;amp;e);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;saif\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;print_path(s,e);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;%d\n&quot;,cost[s][e]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/4089147898744540405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/directed-path-floydwarshall-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4089147898744540405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/4089147898744540405'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/directed-path-floydwarshall-algorithm.html' title='Directed path Floyd_Warshall algorithm'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry><entry><id>tag:blogger.com,1999:blog-2052758358902108656.post-3971551297498240990</id><published>2012-02-07T23:43:00.003+06:00</published><updated>2012-02-07T23:43:51.468+06:00</updated><title type='text'>FloydWarshall MIN-MAX Distance</title><content type='html'>&lt;span style=&quot;color: purple;&quot;&gt;/***&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; FloydWarshall MIN-MAX Distance&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&amp;nbsp; &amp;nbsp; Author : Md.Saiful Islam&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;***/&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#define MAX(aa,bb) (aa&amp;gt;bb?aa:bb)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;#define MIN(aa,bb) (aa&amp;lt;bb?aa:bb)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Road[102][102];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int Node,Edge,test,c1,c2,cost,q1,q2;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;void Floyed_Warshall()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int k,i,j;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Road[i][i]=0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(k=1;k&amp;lt;=Node;k++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=Node;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Road[i][j] = MIN(Road[i][j], MAX(Road[i][k],Road[k][j]));&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;int main()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i,kase=0,j;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(scanf(&quot;%d %d %d&quot;,&amp;amp;Node,&amp;amp;Edge,&amp;amp;test)==3 &amp;amp;&amp;amp; (Node || Edge || test))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=Node;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for(j=1;j&amp;lt;=Node;j++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Road[i][j]=10000;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=Edge;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d %d %d&quot;,&amp;amp;c1,&amp;amp;c2,&amp;amp;cost);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Road[c1][c2]=cost; Road[c2][c1]=cost;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Floyed_Warshall();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(kase&amp;gt;0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Case #%d\n&quot;,++kase);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for(i=1;i&amp;lt;=test;i++)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;scanf(&quot;%d %d&quot;,&amp;amp;q1,&amp;amp;q2);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if(Road[q1][q2]==10000)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;printf(&quot;no path\n&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;printf(&quot;%d\n&quot;,Road[q1][q2]);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Input:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;7 9 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 2 50&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 3 60&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;2 4 120&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;2 5 90&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;3 6 50&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 6 80&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 7 70&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 7 40&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;6 7 140&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;2 6&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;6 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;7 6 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 2 50&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 3 60&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;2 4 120&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;3 6 50&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;4 6 80&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;5 7 40&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;7 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;1 7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;2 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Output:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;80&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;60&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;60&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;Case #2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;40&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;no path&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;80&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://saifsust.blogspot.com/feeds/3971551297498240990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://saifsust.blogspot.com/2012/02/floydwarshall-min-max-distance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3971551297498240990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2052758358902108656/posts/default/3971551297498240990'/><link rel='alternate' type='text/html' href='http://saifsust.blogspot.com/2012/02/floydwarshall-min-max-distance.html' title='FloydWarshall MIN-MAX Distance'/><author><name>Saiful</name><uri>http://www.blogger.com/profile/10996922407449918815</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='31' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXD1WcT2Xwe0z3TGSoVzzQcV9iDi7g34V3s2w4omuSrZW8MaSTjF9alrKeV4cN-qastlcc91UFx9xLcz8L2LYjfGy9J7oxFWnB-X6bi1mRtNFzxHtgmnWwWmCGuSW8xg/s220/saiful.jpg'/></author><thr:total>0</thr:total><georss:featurename>Dhaka, Bangladesh</georss:featurename><georss:point>23.709921 90.407143000000019</georss:point><georss:box>23.596680000000003 90.312930500000022 23.823162 90.501355500000017</georss:box></entry></feed>