Executing… Test 1: TEST OK [0.000 secs, 204 KB] Test 2: TEST OK [0.000 secs, 204 KB] Test 3: TEST OK [0.000 secs, 208 KB] Test 4: TEST OK [0.000 secs, 208 KB] Test 5: TEST OK [0.000 secs, 204 KB] Test 6: TEST OK [0.011 secs, 208 KB] Test 7: TEST OK [0.011 secs, 208 KB]
All tests OK. Your program (‘zerosum’) produced all correct answers! This is your submission #3 for this problem. Congratulations!
program test; type node=array[0..8]of integer; var n:3..9; a:array[1..9]of integer; b1:array[1..9]of integer; total:longint; b:node; procedureprint(c:node); var i:integer; begin for i:=2to n do begin case c[i-1] of 1:begin write(a[i-1],' '); end; 2:begin write(a[i-1],'+'); end; 3:begin write(a[i-1],'-'); end; end; end; writeln(a[n]); {for i:=1 to n-1 do write(c[i],' '); writeln;} end; procedurepd(c:node); var i,temp,temp2:integer; begin fillchar(b1,sizeof(b1),0); total:=0;temp:=0; for i:=1to n do begin if c[i]=1then begin if c[i-1]=1then total:=total*10+a[i+1]; if c[i-1]<>1then begin total:=a[i]; total:=total*10+a[i+1]; end; if c[i+1]<>1then begin inc(temp);b1[temp]:=total;end; end; end; temp:=1;temp2:=0; if c[1]=1thenbegin total:=b1[1];inc(temp2);end else total:=a[1]; while temp<n do begin if c[temp]<>1then begin if c[temp+1]<>1then case c[temp] of 2:total:=total+a[temp+1]; 3:total:=total-a[temp+1]; end else begin inc(temp2); case c[temp] of 2:total:=total+b1[temp2]; 3:total:=total-b1[temp2]; end; for i:=temp+1to n do if i<>1then begin temp:=i; break; end; end; end; inc(temp); end; if total=0then print(c) elseexit; end; proceduredfs(x:integer;b:node); var i:integer; begin if (x=n) then begin pd(b); exit; end; for i:=1to3do begin b[x]:=i; if x+1<=n then dfs(x+1,b); end; end; procedureinit; var i:integer; begin readln(n); fillchar(a,sizeof(a),0); for i:=1to n do a[i]:=i; b[0]:=0; end; begin assign(input,'zerosum.in'); reset(input); assign(output,'zerosum.out'); rewrite(output); init; dfs(1,b); close(input); close(output); end.