<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "Задача Мој Термин"]]></title>
		<link>http://mendo.mk/jforum/posts/list/6.page</link>
		<description><![CDATA[Latest messages posted in the topic "Задача Мој Термин"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>Задача Мој Термин</title>
				<description><![CDATA[ [code]<br /> #include &lt;bits/stdc++.h&gt;<br /> using namespace std;<br />  <br />  <br /> int n,nepoznati=0,res=0;<br /> char input[101];<br /> set &lt;int&gt; solution[101];<br />  <br /> void refh(int position,int nepoznati)<br /> {<br />     if(nepoznati==0)<br />     {<br />         for(int i=0;i&lt;n;i++)<br />         {<br />             int curr=(int)input[i]-'0';<br />  <br />             for(int j=i;j&lt;i+curr;j++)<br />             {<br />                 if((int)input[j]-'0'!=curr)<br />                     return;<br />             }<br />             i+=curr-1;<br />  <br />         }<br />     res++;<br />     }<br />     if(res&gt;1)<br />     {<br />  <br />         position=101;<br />         nepoznati=101;<br />     }<br />     for(int i=position;i&lt;n;i++)<br />     {<br />         for(auto next : solution[i])<br />         {<br />  <br />             input[i]=char(next+'0');<br />             refh(i+1,nepoznati-1);<br />  <br />  <br />         }<br />  <br />     }<br />  <br />  <br /> }<br />  <br /> int main()<br /> {<br />     cin &gt;&gt; n;<br />  <br />     for(int i=0;i&lt;n;i++)<br />     {<br />         cin &gt;&gt; input[i];<br />         if(input[i]=='N')<br />             nepoznati++;<br />     }<br />     for(int i=0;i&lt;n;i++) //Possible solutions<br />     {<br />         if(input[i]=='N'){<br />             solution[i].insert(1);<br />         if(i&gt;0 && input[i-1]!='N')<br />         {<br />             solution[i].insert((int)input[i-1]-'0');<br />         }<br />         if(i&lt;n-1 && input[i+1]!='N')<br />         {<br />             solution[i].insert((int)input[i+1]-'0');<br />         }<br />         if(i&gt;0 && input[i-1]=='N')<br />         {<br />            for(int j=i-2;j&gt;=0;j--)<br />            {<br />                if(input[j]!='N')<br />                {<br />                    solution[i].insert((int)input[j]-'0');<br />                    break;<br />                }<br />            }<br />         }<br />          if(i&lt;n-1 && input[i+1]=='N')<br />         {<br />             for(int j=i+2;j&lt;n;j++)<br />            {<br />                if(input[j]!='N')<br />                {<br />                    solution[i].insert((int)input[j]-'0');<br />                    break;<br />                }<br />            }<br />         }<br />         }<br />     }<br />     refh(0,nepoznati);<br />  <br />    // cout &lt;&lt; res &lt;&lt;endl;<br />     if(res==1)<br />     {<br />         cout &lt;&lt; "DA";<br />         return 0;<br />     }<br />     cout &lt;&lt; "NE";<br /> }[/code]<br /> <br /> Дали би можела задачата да се реши рекурзивно?]]></description>
				<guid isPermaLink="true">http://mendo.mk/jforum/posts/preList/700/3810.page</guid>
				<link>http://mendo.mk/jforum/posts/preList/700/3810.page</link>
				<pubDate><![CDATA[Mon, 15 Apr 2019 13:07:04]]> GMT</pubDate>
				<author><![CDATA[ Krenkov]]></author>
			</item>
			<item>
				<title>Задача Мој Термин</title>
				<description><![CDATA[ [quote=Krenkov]Дали би можела задачата да се реши рекурзивно?[/quote]<br /> Не на овој начин. Имаш премногу состојби за разгледување.<br /> <br /> Но, многу алгоритми може да се реализираат со помош на рекурзија - на пример, динамичко програмирање (со мемоизација).<br /> Инаку, ако бараш решение на задачава, може да провериш тука: <a class="snap_shots" href="http://mendo.mk/jforum/posts/list/565.page" target="_blank" rel="nofollow">http://mendo.mk/jforum/posts/list/565.page</a>]]></description>
				<guid isPermaLink="true">http://mendo.mk/jforum/posts/preList/700/3811.page</guid>
				<link>http://mendo.mk/jforum/posts/preList/700/3811.page</link>
				<pubDate><![CDATA[Wed, 17 Apr 2019 11:51:29]]> GMT</pubDate>
				<author><![CDATA[ petarsor]]></author>
			</item>
	</channel>
</rss>