Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

模拟水题……25行无压力~~

Posted by This_poet at 2011-10-24 23:11:10 on Problem 1068
代码:
program poj1068;//By_Thispoet
var
	i,j,p,m,n,te		:longint;
	ans,stack			:array[0..50]of longint;
	st					:string;
	
begin
	readln(te);
	while te>0 do begin	
		readln(n);p:=0;st:='';
		for i:=1 to n do begin
			read(m);
			while p<m do begin
				st:=st+'(';inc(p);
			end;st:=st+')';
		end;m:=0;j:=0;fillchar(stack,sizeof(stack),0);
		for i:=1 to length(st) do if st[i]=')' then begin	
			inc(j);ans[j]:=stack[m];dec(m);stack[m]:=stack[m+1]+stack[m];
		end else begin
			inc(m);stack[m]:=1;
		end;
		for i:=1 to n-1 do write(ans[i],' ');writeln(ans[n]);
		dec(te);
	end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator