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

为什么wa呀?

Posted by yipeng at 2004-05-24 16:46:21 on Problem 1415
#include "stdio.h"
void main(){
	int t,i,j,k,n,top,base,num,top1;
    scanf("%d",&t);
	int a1[110][110];
	int stack[2000];
	for(i=1;i<=t;i++){
		for(j=1;j<110;j++){
			for(k=1;k<110;k++){
				a1[j][k]=0;
			}
		}
		top=0;
		base=1;
		num=0;
		scanf("%d",&n);
		while(n!=0){
			if(n>0){
				top++;
				stack[top]=n;
				num++;
				top1=top-1;
				if(top1>=1){
					while(stack[top1]==0)
						top1--;
					stack[top]--;
					stack[top1]--;
					a1[top1][top]++;
					a1[top][top1]++;
				}
			}
			else{
				while(stack[base]==0){
					base++;
				}
				while(stack[top]==0){
					top--;
				}
				stack[base]--;
				stack[top]--;
                a1[top][base]++;
				a1[base][top]++;
			}
			scanf("%d",&n);
		}
		while(top!=base&&top!=0){
			while(stack[top]==0){
				top--;
				if(top==base)
					break;
			}
			top1=top-1;
			while(stack[top1]==0)
				top1--;
			a1[top][top1]++;
			a1[top1][top]++;
			stack[top]--;
			stack[top1]--;

		}
		for(j=1;j<=num;j++){
			printf("%d",j);
			for(k=1;k<=num;k++){
				while(a1[j][k]>=1){
				    printf(" %d",k);
					a1[j][k]--;
				}
			}
			printf("\n");
		}
	}
}

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