|
|
back to boardany1 give me some test plz. Var n,s,k,i :integer; t :char; a :array[0..1001] of boolean; b :array[0..1001] of integer; procedure writt(x,y:integer); Var i :integer; begin for i:=x to y do write(ord(a[i])); end; procedure add; Var i,p :integer; begin if k=0 then begin writt(1,s); write(0); end else begin b[n]:=0; for i:=n-1 downto 0 do b[i]:=b[i+1]+ord(a[i+1]); if k+b[0]>=(n+1) then {add 0} begin p:=-1; repeat inc(p); until (k+b[p]) mod (n+1)=0; writt(1,p); write(0); writt(p+1,s); end else begin p:=-1; repeat inc(p); until (k+p+b[p]) mod (n+1)=0; writt(1,p-1); write(1); writt(p,s); end; end; end; procedure chn; begin if k=0 then writt(1,n) else begin writt(1,k-1); if not a[k] then while true do; write(0); writt(k+1,n); end end; procedure del; Var i,p :integer; begin if k=0 then writt(1,n) else begin b[n+1]:=0; for i:=n downto 0 do b[i]:=b[i+1]+ord(a[i+1]); p:=0; repeat inc(p); until (k-b[p]-p*(ord(a[p]))+n+1) mod (n+1)=0; writt(1,p-1); writt(p+1,n+1); end; end; begin readln(n); while not eof do begin s:=0; while (not eoln) and (not eof) do begin read(t); if (ord(t)=48) or (ord(t)=49) then begin inc(s); a[s]:=ord(t)=49; end; end; readln; k:=0; for i:=1 to s do if a[i] then k:=(k+i) mod (n+1); if s =n-1 then add else if s=n then chn else if s=n+1 then del; if (s>=n-1) and (s<=n+1) then writeln; end; end. I Got AC, but if you have Free-Time, see how my mistake was funny! Hi there, After 20Wa, i see my programs answers right for tescases, sepeartely (i.e. one senteces per test.) but suddenly i saw that my program after 10test for n=5 which in 2nd sentence 1100-->11100 in 10th i again write 1100 and saw incredible!: answer of 1100 was 01100!!!! where was my mistake?!! Just in Add Procedure i read value of a[n] but sentence was only n-1bit and nth value was by previouses tests! so just i insert this line after begin of add procedure: A[N]:=False; And Got AC :P wish best times for you Aidin_n7@hotmail.com |
|
|