首页 > 代码库 > noi4_1_1999[日志排序]

noi4_1_1999[日志排序]

复杂的判断&多余的空格=n个wrong answer

type event=record            st:string[100];            year,mon,day,hour,min,sec,lse:integer;            t:longint;           end;var a:array[1..10000] of event;    n:longint;    function bigger(i,j:integer):boolean;begin if a[i].year>a[j].year then exit(true); if a[i].year<a[j].year then exit(false); if a[i].mon>a[j].mon then exit(true); if a[i].mon<a[j].mon then exit(false); if a[i].day>a[j].day then exit(true); if a[i].day<a[j].day then exit(false); if a[i].hour>a[j].hour then exit(true); if a[i].hour<a[j].hour then exit(false); if a[i].min>a[j].min then exit(true); if a[i].min<a[j].min then exit(false); if a[i].sec>a[j].sec then exit(true); if a[i].sec<a[j].sec then exit(false); if a[i].lse>a[j].lse then exit(true); if a[i].lse<a[j].lse then exit(false); exit(false);end;    procedure scanf;var k:longint;    s:string;    tmp:real;begin n:=0; readln(s); while s<>‘‘ do  begin   inc(n);   a[n].st:=s;   while s[1]=‘ ‘ do delete(s,1,1);   k:=pos(‘ ‘,s);   delete(s,1,k);   while s[1]=‘ ‘ do delete(s,1,1);   k:=pos(‘-‘,s);   val(copy(s,1,k-1),a[n].year);   delete(s,1,k);   k:=pos(‘-‘,s);   val(copy(s,1,k-1),a[n].mon);   delete(s,1,k);   k:=pos(‘ ‘,s);   val(copy(s,1,k-1),a[n].day);   delete(s,1,k);   while s[1]=‘ ‘ do delete(s,1,1);   k:=pos(‘:‘,s);   val(copy(s,1,k-1),a[n].hour);   delete(s,1,k);   k:=pos(‘:‘,s);   val(copy(s,1,k-1),a[n].min);   delete(s,1,k);   k:=pos(‘,‘,s);   val(copy(s,1,k-1),a[n].sec);   delete(s,1,k);   k:=pos(‘ ‘,s);   val(copy(s,1,k-1),a[n].lse);   delete(s,1,k);   while s[1]=‘ ‘ do delete(s,1,1);   k:=pos(‘(‘,s);   val(copy(s,1,k-1),tmp);   a[n].t:=trunc(tmp*1000);   readln(s);  end;end;procedure sort;var i,j:longint;    tmp:event;begin for i:=1 to n-1 do  for j:=i+1 to n do   if (a[i].t>a[j].t)or((a[i].t=a[j].t)and(bigger(i,j))) then    begin     tmp:=a[i];     a[i]:=a[j];     a[j]:=tmp;    end;end;procedure printf;var i:longint;begin for i:=1 to n do  writeln(a[i].st);end;begin scanf; sort; printf;end.

noi4_1_1999[日志排序]