I found, that I can edit previously posted messages so I cut source code ... I'm not sure, that is correct way to prevent someone to copy-paste method to solve problems ... but I think, that only when source code has errors should be post here...
Last edited by Dominik Michniewski on Wed Sep 11, 2002 8:20 am, edited 1 time in total.
procedure init;
var w : char;
begin
ls := 0; lt := 0;
fillchar(s, sizeof(s), 0);
fillchar(t, sizeof(t), 0);
read(w);
while w <> ' ' do begin
inc(ls);
s[ls] := w;
read(w);
end;
while w = ' ' do read(w);
while (w <> ' ') and not eoln do begin
inc(lt);
t[lt] := w;
read(w);
end;
if w <> ' ' then begin inc(lt); t[lt] := w; end;
readln;
end;
procedure main;
var i,j : integer;
begin
j := 1;
for i := 1 to ls do begin
while (j <= lt) and (s <> t[j]) do inc(j);
if s <> t[j] then begin
writeln('No'); exit;
end
else if i = ls then
if i = ls then writeln('Yes')
else
else inc(j);
end;
end;
begin
assign(input, name1);
reset(input);
assign(output, name2);
rewrite(output);
while not eof do begin
init;
main;
end;
close(input);
close(output);
end.
[/pascal]
Runtime Errors give information about the kind of error that was encountered, so look at that information to solve the problem. In your case you probably got 'Illegal Memory Reference', or something like that, which means that the program tries to access memory that doesn't belong to it.
Since you only allocated 10000 bytes of memory for the two inputbuffers, they are the most probable offenders. Try to increase their sizes.
Yes, it is possible, why do you ask? It is obvious that this would cause a runtime error, so if you get RE in a problem like this you should first try to allocate more memory before asking in the forum, and please use existing threads (there is one about this problem). In this case the string is not longer than 500000 and perhaps shorter, but if you want to be sure use 500000 as upper limit.
if someone could explain me why I get WA on this, it would be appreciated... I tested it with everything I could think of and it worked fine....
here is the code
[cpp]
#include <iostream.h>
#include <string.h>
#define MX 1000000
main() {
char o[MX],e[MX]; /* original, encoded */
int i,j,ol,el;