<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<!-- DOMjudge version 3.3.2 -->
<title>Source: s1031</title>
<link rel="shortcut icon" href="../images/favicon.png" type="image/png" />
<link rel="stylesheet" href="../style.css" type="text/css" />
<link rel="stylesheet" href="style_jury.css" type="text/css" />
<script type="text/javascript" src="../js/sorttable.js"></script>
<script type="text/javascript" src="../js/domjudge.js"></script>
</head>
<body>

<h2>Source code for submission s1031</h2>

<p><a href="#diff">Go to diff to previous submission</a></p>

<div class="tabber"><div class="tabbertab"><h2 class="filename"><a name="source0"></a>bugs.c</h2> 

<pre class="c" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include&lt;stdio.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include&lt;string.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #339933;">#include&lt;stdlib.h&gt;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">int</span> N<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">int</span> rozdiel<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">char</span> riadok<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2000005</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">char</span> vzorka<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1005</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">int</span> dlzkaVzorka<span style="color: #339933;">,</span>dlzkaRiadok<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #993333;">char</span> <span style="color: #339933;">*</span>x<span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html"><span style="color: #000066;">scanf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d %s &quot;</span><span style="color: #339933;">,&amp;</span>N<span style="color: #339933;">,</span> vzorka<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>N<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			dlzkaVzorka <span style="color: #339933;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span style="color: #000066;">strlen</span></a><span style="color: #009900;">&#40;</span>vzorka<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<a href="http://www.opengroup.org/onlinepubs/009695399/functions/fgets.html"><span style="color: #000066;">fgets</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #339933;">,</span><span style="color: #0000dd;">2000005</span><span style="color: #339933;">,</span>stdin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			dlzkaRiadok <span style="color: #339933;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span style="color: #000066;">strlen</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strstr.html"><span style="color: #000066;">strstr</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #339933;">,</span>vzorka<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span>riadok<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					x <span style="color: #339933;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strstr.html"><span style="color: #000066;">strstr</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #339933;">,</span>vzorka<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					rozdiel <span style="color: #339933;">=</span> x <span style="color: #339933;">-</span> riadok<span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					<a href="http://www.opengroup.org/onlinepubs/009695399/functions/memmove.html"><span style="color: #000066;">memmove</span></a><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>x <span style="color: #339933;">+</span> dlzkaVzorka<span style="color: #339933;">,</span>dlzkaRiadok <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>rozdiel <span style="color: #339933;">+</span> dlzkaVzorka<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					dlzkaRiadok <span style="color: #339933;">=</span> <a href="http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html"><span style="color: #000066;">strlen</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strstr.html"><span style="color: #000066;">strstr</span></a><span style="color: #009900;">&#40;</span>riadok<span style="color: #339933;">,</span>vzorka<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">						<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span>riadok<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">						<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">					<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">				<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">			<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #009900;">&#125;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</div></li></ol></pre></div></div><h2><a name="diff"></a>Diff to submission <a href="846">s846</a></h2>
<div class="tabber"><div class="tabbertab"><h2 class="filename"><a name="diff"></a>bugs.c</h2>

<pre class="output_text"><span class='diff-del'>--- c4.s846.cteam074.bugs.c.0.bugs.c</span>
<span class='diff-add'>+++ c4.s1031.cteam074.bugs.c.0.bugs.c</span>
@@ -3,45 +3,32 @@
 #include&lt;stdlib.h&gt;
 
<span class='diff-del'>-</span>
<span class='diff-del'>-        char riadok[2000005];</span>
<span class='diff-del'>-        char vzorka[1005];</span>
<span class='diff-del'>-        </span>
<span class='diff-del'>-int kontrola(int i,int dlzka){</span>
<span class='diff-del'>-        int x;</span>
<span class='diff-del'>-        </span>
<span class='diff-del'>-        for(x=0;x&lt;dlzka;x++){</span>
<span class='diff-del'>-                if(riadok[i-dlzka+x+1] != vzorka[x]){</span>
<span class='diff-del'>-                        return i;</span>
<span class='diff-del'>-                }</span>
<span class='diff-del'>-        }</span>
<span class='diff-del'>-        return (i-dlzka);</span>
<span class='diff-del'>-}</span>
<span class='diff-del'>-</span>
 int main(void){
         int N;
<span class='diff-del'>-        int dlzkaVzorka;</span>
<span class='diff-del'>-        char x;</span>
<span class='diff-del'>-        int i,u;</span>
<span class='diff-add'>+        int rozdiel;</span>
<span class='diff-add'>+        char riadok[2000005];</span>
<span class='diff-add'>+        char vzorka[1005];</span>
<span class='diff-add'>+        int dlzkaVzorka,dlzkaRiadok;</span>
<span class='diff-add'>+        char *x;</span>
         
<span class='diff-del'>-        while((scanf(&quot;%d %s &quot;,&amp;N, vzorka) == 2)){</span>
<span class='diff-del'>-                dlzkaVzorka = strlen(vzorka);</span>
<span class='diff-del'>-                for(u=0;u&lt;N;u++){</span>
<span class='diff-del'>-                        i = 0;</span>
<span class='diff-del'>-                        while(1){</span>
<span class='diff-del'>-                                scanf(&quot;%c&quot;,&amp;x);</span>
<span class='diff-del'>-                                if(x == '\n'){</span>
<span class='diff-del'>-                                        riadok[i] = x;</span>
<span class='diff-del'>-                                        riadok[i+1] = '\0';</span>
<span class='diff-del'>-                                        break;</span>
<span class='diff-del'>-                                }</span>
<span class='diff-del'>-                                else{</span>
<span class='diff-del'>-                                        riadok[i] = x;</span>
<span class='diff-del'>-                                        if(x == vzorka[dlzkaVzorka - 1]){</span>
<span class='diff-del'>-                                                i = kontrola(i,dlzkaVzorka);</span>
<span class='diff-add'>+        while(scanf(&quot;%d %s &quot;,&amp;N, vzorka) == 2){</span>
<span class='diff-add'>+                while(N--){</span>
<span class='diff-add'>+                        dlzkaVzorka = strlen(vzorka);</span>
<span class='diff-add'>+                        fgets(riadok,2000005,stdin);</span>
<span class='diff-add'>+                        dlzkaRiadok = strlen(riadok);</span>
<span class='diff-add'>+                        if(!strstr(riadok,vzorka)){</span>
<span class='diff-add'>+                                printf(&quot;%s&quot;,riadok);</span>
<span class='diff-add'>+                        }</span>
<span class='diff-add'>+                        else{</span>
<span class='diff-add'>+                                while(1){</span>
<span class='diff-add'>+                                        x = strstr(riadok,vzorka);</span>
<span class='diff-add'>+                                        rozdiel = x - riadok;</span>
<span class='diff-add'>+                                        memmove(x,x + dlzkaVzorka,dlzkaRiadok - (rozdiel + dlzkaVzorka) + 1);</span>
<span class='diff-add'>+                                        dlzkaRiadok = strlen(riadok);</span>
<span class='diff-add'>+                                        if(!strstr(riadok,vzorka)){</span>
<span class='diff-add'>+                                                printf(&quot;%s&quot;,riadok);</span>
<span class='diff-add'>+                                                break;</span>
                                         }
<span class='diff-del'>-                                        i++;</span>
                                 }
                         }
<span class='diff-del'>-                        printf(&quot;%s&quot;,riadok);</span>
                 }
         }
</pre>

</div></div>
</body>
</html>
