http://acm.timus.ru/problem.aspx?space=1&num=1546&locale=ru
http://acm.timus.ru/Supplement/BlackBox/BlackBox.aspx
http://acm.timus.ru/submit.aspx?space=1&num=1546
решение
сортировка по-японски pascal
- function IsLess(const pa, pb: PChar): Boolean;
- const D = ['0'..'9']; D0 = D+[#0];
- var
- a, b, ta, tb, za, zb: PChar;
- begin
- a:=pa; b:=pb;
- while (a^<>#0) and (b^<>#0) do begin
- while not (a^ in D0) and not (b^ in D0) and (a^=b^) do begin
- Inc(a); Inc(b);
- end;
- if (a^ in D) and (b^ in D) then begin
- za:=a; while a^='0' do Inc(a); ta:=a; while a^ in D do Inc(a);
- zb:=b; while b^='0' do Inc(b); tb:=b; while b^ in D do Inc(b);
- if a-ta<>b-tb then begin
- IsLess:=a-ta<b-tb; Exit;
- end else begin
- a:=ta; b:=tb;
- while (a^ in D) and (b^ in D) and (a^=b^) do begin
- Inc(a); Inc(b);
- end;
- if a^ in D then Break;
- if a-za<>b-zb then begin
- IsLess:=a-za<b-zb; Exit;
- end;
- end;
- end else Break;
- end;
- IsLess:=a^<b^;
- end;
Комментариев нет:
Отправить комментарий