Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么会超时?请过的人看一下,拜托了,神牛大人门!!!!!(pascal 代码 )

Posted by chen950209 at 2011-08-06 16:05:09 on Problem 3349
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator