援助方案
坐标和图形数比较小,每处理一个图形暴力枚举可能在图形里的整点然后判断即可。圆用距离公式,矩形。。。,三角形用向量。注意圆可能覆盖到二三四象限。
Codeuses math;var f:array[-60..110,-60..110] of boolean; ans:int64; n,i:longint; ch:char;function cross(x1,y1,x2,y2:longint):longint; begin Cross:=x1*y2-x2*y1; end;function ok(a,b,c:longint):boolean; begin ok:=false; if(a>=0)and(b>=0)and(c>=0)then ok:=true; if(a<=0)and(b<=0)and(c<=0)then ok:=true; end;procedure Triangle; var i,j,x1,x2,x3,xa,xb,xc,y1,y2,y3,ya,yb,yc,up,down,left,right:longint; begin readln(x1,y1,x2,y2,x3,y3); xa:=x2-x1;ya:=y2-y1; xb:=x3-x2;yb:=y3-y2; xc:=x1-x3;yc:=y1-y3; up:=max(max(y1,y2),y3); down:=min(min(y1,y2),y3); right:=max(max(x1,x2),x3); left:=min(min(x1,x2),x3); for i:=left to right do for j:=down to up do if(not f[i][j])and (ok(Cross(i-x1,j-y1,xa,ya), Cross(i-x2,j-y2,xb,yb), Cross(i-x3,j-y3,xc,yc)) ) then begin inc(ans); f[i][j]:=true; end; end;procedure circle; var x,y,r,i,j,rr:longint; begin readln(x,y,r);rr:=r*r; for i:=x-r to x+r do for j:=y-r to y+r do if (not f[i][j])and ((i-x)*(i-x)+(j-y)*(j-y)<=rr) then begin inc(ans); f[i][j]:=true; end; end;procedure Square; var x,y,l,i,j:longint; begin readln(x,y,l); for i:=x to x+l do for j:=y to y+l do if not f[i][j] then begin inc(ans); f[i][j]:=true; end; end;BEGINreadln(n);for i:=1 to n do begin read(ch); case ch of 'T':Triangle; 'C':circle; 'S':Square; end; end;writeln(ans);END.
数字游戏 标程是单调队列。我用数组模拟双链表A掉的。实际上我是维护了一个单调不降的线性表。内存泄露神马的不管了。
Codevar ch:char; next,pre,num:array[0..5000000] of longint; i,j,h,t,n,len:longint;BEGINreset(input);rewrite(output);while not eoln do begin read(ch); inc(len); num[len]:=ord(ch)-ord('0'); end;readln(n);if n=len then begin writeln(0);halt;end;for i:=1 to len do begin pre[i]:=i-1; next[i]:=i+1; end;pre[1]:=0;next[len]:=0;h:=1;t:=len;i:=1;while n>0 do begin while(i<>0)and(num[i]<=num[next[i]])do i:=next[i]; if i=0 then i:=t; dec(n);dec(len); next[pre[i]]:=next[i]; pre[next[i]]:=pre[i]; if pre[i]=0 then h:=next[i]; if next[i]=0 then t:=pre[i]; i:=pre[i];if i=0 then i:=h; end;i:=h;while(i<>0)and(num[i]=0)do i:=next[i]; if i=0 then writeln(0) else begin while(i<>0)do begin write(num[i]); i:=next[i]; end; writeln; end;END.
哈密顿路
NPC问题做不来。
总结
610人参赛,298人有分,两个AK的,3个280以上,我150分,69名,如果第二题仔细一点就好了,200分的话是26名。写完程序必须自己造数据。