2024年2月16日发(作者:朱涵菡)
type ty=record x,y:integer;end;
var a,b:array[1..100]of integer;
qx,qy:array[0..410000]of longint;
v:array[-100..100,-100..100]of boolean;
var k,i,j,l:longint;
function go:boolean;
var n,i,j,k,h,t,xx,yy:longint;
begin
for i:= 1 to 201 do for j:= 1 to 201 do
v[i-101,j-101]:=false;
readln(n);
for i:=1to n do
readln(a[i],b[i]);
h:=0;t:=1;
qx[1]:=0;qy[1]:=0;
while h begin inc(h); if h>410000 then h:=1; for i:=1 to n do begin xx:=qx[h]+a[i];yy:=qy[h]+b[i]; if (abs(xx)<=100)and(abs(yy)<=100)and(not(v[xx,yy]) )then begin inc(t); if t>410000 then t:=1; qx[t]:=xx;qy[t]:=yy; v[xx,yy]:=true; end; end; if v[1,0]and v[-1,0] and v[0,1] and v[0,-1] then exit(true); end; exit(false); end; begin assign(input,'');assign(output,''); reset(input);rewrite(output); type ty=record x,y:integer;end; var a,b:array[1..100]of integer; qx,qy:array[0..410000]of longint; v:array[-100..100,-100..100]of boolean; var k,i,j,l:longint; function go:boolean; var n,i,j,k,h,t,xx,yy:longint; a,b:array[1..100]of integer; qx,qy:array[0..410000]of longint; v:array[-100..100,-100..100]of boolean; begin for i:= 1 to 201 do for j:= 1 to 201 do v[i-101,j-101]:=false; readln(n); for i:=1to n do readln(a[i],b[i]); h:=0;t:=1; qx[1]:=0;qy[1]:=0; while h begin inc(h); if h>410000 then h:=1; for i:=1 to n do begin xx:=qx[h]+a[i];yy:=qy[h]+b[i]; if (abs(xx)<=100)and(abs(yy)<=100)and(not(v[xx,yy]) )then begin inc(t); if t>410000 then t:=1; qx[t]:=xx;qy[t]:=yy; v[xx,yy]:=true; end; end; if v[1,0]and v[-1,0] and v[0,1] and v[0,-1] then exit(true); end; exit(false); end; begin readln(k); for l:=1 to k do if go then writeln('NIE'); close(input); close(output); end. writeln('TAK') assign(input,'');assign(output,''); reset(input);rewrite(output); readln(k); for l:=1 to k do else if go then writeln('TAK') else writeln('NIE'); close(input); close(output); end. 过了 202 崩掉了 注意加红字的部分 放在函数里与函数外 区别很大 关键是放在函数里每次调用都会申请空间而不释放
2024年2月16日发(作者:朱涵菡)
type ty=record x,y:integer;end;
var a,b:array[1..100]of integer;
qx,qy:array[0..410000]of longint;
v:array[-100..100,-100..100]of boolean;
var k,i,j,l:longint;
function go:boolean;
var n,i,j,k,h,t,xx,yy:longint;
begin
for i:= 1 to 201 do for j:= 1 to 201 do
v[i-101,j-101]:=false;
readln(n);
for i:=1to n do
readln(a[i],b[i]);
h:=0;t:=1;
qx[1]:=0;qy[1]:=0;
while h begin inc(h); if h>410000 then h:=1; for i:=1 to n do begin xx:=qx[h]+a[i];yy:=qy[h]+b[i]; if (abs(xx)<=100)and(abs(yy)<=100)and(not(v[xx,yy]) )then begin inc(t); if t>410000 then t:=1; qx[t]:=xx;qy[t]:=yy; v[xx,yy]:=true; end; end; if v[1,0]and v[-1,0] and v[0,1] and v[0,-1] then exit(true); end; exit(false); end; begin assign(input,'');assign(output,''); reset(input);rewrite(output); type ty=record x,y:integer;end; var a,b:array[1..100]of integer; qx,qy:array[0..410000]of longint; v:array[-100..100,-100..100]of boolean; var k,i,j,l:longint; function go:boolean; var n,i,j,k,h,t,xx,yy:longint; a,b:array[1..100]of integer; qx,qy:array[0..410000]of longint; v:array[-100..100,-100..100]of boolean; begin for i:= 1 to 201 do for j:= 1 to 201 do v[i-101,j-101]:=false; readln(n); for i:=1to n do readln(a[i],b[i]); h:=0;t:=1; qx[1]:=0;qy[1]:=0; while h begin inc(h); if h>410000 then h:=1; for i:=1 to n do begin xx:=qx[h]+a[i];yy:=qy[h]+b[i]; if (abs(xx)<=100)and(abs(yy)<=100)and(not(v[xx,yy]) )then begin inc(t); if t>410000 then t:=1; qx[t]:=xx;qy[t]:=yy; v[xx,yy]:=true; end; end; if v[1,0]and v[-1,0] and v[0,1] and v[0,-1] then exit(true); end; exit(false); end; begin readln(k); for l:=1 to k do if go then writeln('NIE'); close(input); close(output); end. writeln('TAK') assign(input,'');assign(output,''); reset(input);rewrite(output); readln(k); for l:=1 to k do else if go then writeln('TAK') else writeln('NIE'); close(input); close(output); end. 过了 202 崩掉了 注意加红字的部分 放在函数里与函数外 区别很大 关键是放在函数里每次调用都会申请空间而不释放