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

Help~~

Posted by found at 2008-12-19 14:56:33 on Problem 1147
I've sovled it, but I wander what data trapped my origin code.
Please help me!Thanks very much!

#include <iostream>
using namespace std;
int org[3001];
int adj[3001][2];
int main(){
	int len, i, j, one= 0, k;
	scanf("%d",&len);
	memset(adj,0,sizeof(adj));
	for( i= 0; i< len; i++ ){
		scanf("%d",&adj[i][0]);
		if( adj[i][0] )	one++;
	}
	for( i= len-1; i>= len-one; i-- )
		adj[i][1]= 1;
	for( k= 0, i= 0; k< len; k++ ){
		org[k]= adj[i][0];
		adj[i][0]= -1;
		for( j= 0; j< len; j++ )
			if( adj[i][1]== adj[j][0] ){
				i= j;
				break;
			}
	}
	for( i= 1; i< len; i++ )
		printf("%d ",org[i]);
	printf("%d \n",org[0]);
	return 0;   
}

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