uva10273 常数优化失败……
同样的算法http://www.cnblogs.com/staginner/archive/2011/10/26/2225649.html C++就能过,pascal死活过不了……
怀疑Uva没有开-O2 = =
求常数优化
# | Problem | Verdict | Language | Run Time | Submission Date | |
11661422 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 11:41:13 |
11661382 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 11:35:06 |
11661336 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 11:29:44 |
11661253 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 11:14:13 |
11661190 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 10:59:35 |
11661160 | 10273 | Eat or Not to Eat? | Time limit exceeded | PASCAL | 3.000 | 2013-04-24 10:51:02 |
TAT
program p10273; Const lcm:array[1..10] of longint=(1,2,6,12,60,60,420,840,2520,2520); Var a:array[0..1000,0..9] of longint; k,prev,next:array[0..1002] of longint; t,n,i,j,last,ate,o,u,day,daymax,circle,h:longint; only,kill:boolean; Procedure fopen; begin assign(input,'p10273.in'); assign(output,'p10273.out'); reset(input); rewrite(output); end; Procedure fclose; begin close(input); close(output); end; Procedure Delete(P:longint);inline; begin if prev[p]<>0 then next[prev[p]]:=next[p] else h:=next[p]; if next[p]<>0 then prev[next[p]]:=prev[p]; end; Function gcd(a,b:longint):longint; begin if b<>0 then exit(gcd(b,a mod b)) else exit(a); end; begin readln(t); while t>0 do begin dec(t); readln(n); daymax:=1; //fillchar(f,sizeof(f),0); for i:=1 to n do begin read(k[i]); o:=gcd(daymax,k[i]); daymax:=k[i]*daymax div o; for j:=0 to k[i]-1 do read(a[i,j]); readln; end; h:=1; for i:=1 to n do begin prev[i]:=i-1; next[i]:=i+1; end; next[n]:=0; ate:=0;last:=0; for circle:=0 to maxlongint do begin kill:=false; for day:=1 to daymax do begin u:=maxlongint;o:=0;only:=true; i:=h; while i>0 do begin if a[i,(day-1) mod k[i]]<u then begin u:=a[i,(day-1) mod k[i]]; o:=i; only:=true; end else if a[i,(day-1) mod k[i]]=u then only:=false; i:=next[i]; end; if o=0 then break; if only then begin Delete(o);kill:=true;last:=day+daymax*circle;inc(ate);end; end; if not kill then break; end; writeln(n-ate,' ',last); end; end.