Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么会超时?请过的人看一下,拜托了,神牛大人门!!!!!(pascal 代码 )var n:longint; a:array[1..6] of longint; f:array[1..200000,1..6] of longint; i,j,x,y,sum,k,t,yi,num:longint; hash,p:array[0..100000] of longint; begin assign(input,'1.in'); reset(input); readln(n); fillchar(a,sizeof(a),0); fillchar(hash,sizeof(hash),0); fillchar(p,sizeof(p),0); num:=0; for i:=1 to n do begin for j:=1 to 6 do begin read(x); a[j]:=x; y:=y+x; end; for j:=1 to 5 do for k:=j+1 to 6 do if a[j]>a[k] then begin yi:=a[j]; a[j]:=a[k]; a[k]:=yi; end; sum:=y mod 99991; if hash[sum]<>0 then begin for j:=p[sum] to num do begin t:=1; for k:=1 to 6 do if f[j][k]<>a[k] then begin t:=0; break; end; if t=1 then begin writeln('Twin snowflakes found.'); exit; end; end; inc(hash[sum]); inc(num); for j:=1 to 6 do f[num,j]:=a[j]; end else begin inc(hash[sum]); inc(num); for j:=1 to 6 do f[num,j]:=a[j]; p[sum]:=num; end; y:=0; fillchar(a,sizeof(a),0); end; writeln('No two snowflakes are alike.'); close(input); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator