Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- var
- y1,y2 : array [0..100000] of integer;
- sols : array [1..100000] of integer;
- s1,s2 : string;
- i,l,p,f1,f2 : integer;
- function comp(x : integer) : boolean;
- var i : integer;
- a : boolean;
- begin
- a := true;
- for i := 1 to x do
- if s1[i] <> s2[l-x+i] then
- begin
- a := false;
- exit;
- end;
- comp := a;
- end;
- begin
- assign(input,'k.in');
- assign(output,'k.out');
- reset(input);
- rewrite(output);
- readln(s1);
- readln(s2);
- l := length(s1);
- p := 1;
- f1 := 0;
- f2 := 0;
- for i := 1 to l do
- begin
- if s1[i] = '1' then inc(f1);
- if s2[l-i+1] = '1' then inc(f2);
- if f1 = f2 then
- begin
- sols[p] := i;
- inc(p);
- end;
- end;
- dec(p);
- while (p > 0) and not comp(sols[p]) do dec(p);
- if p = 0 then writeln(l) else writeln(l-sols[p]);
- end.
Add Comment
Please, Sign In to add comment