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 happynp at 2007-06-01 21:46:08 on Problem 1659
#include<iostream>
#include<memory>
using namespace std;
int main()
{ 
  int i,j,t,n;
  int a[12],e[12][12]={0};
  bool DO;
  cin>>t;
  while(t-->0){
     cin>>n;
     for(j=0;j<n;j++)
        cin>>a[j];
	 memset(e,0,sizeof(e));
	 for(i=0;i<n;i++){
	  if(a[i]>0){
		 for(j=i+1;j<n&&a[i]>0;j++){
			if(a[j]>0){
			  e[i][j]++;
              e[j][i]++;
			  a[i]--;
			  a[j]--;
			}
		 }
	  }
	 }
    DO = true;
    for(i=0;i<n;i++)
		if(a[i]>0){
          DO = false;
		  break;
		} 
	if(DO==true){
      cout<<"YES\n";
	  for(i=0;i<n;i++){
	     for(j=0;j<n;j++)
		    cout<<e[i][j]<<" ";
	     cout<<"\n";
	  }
	  cout<<"\n";
	}
	else{
        cout<<"NO\n\n";
	}
  }
	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