Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么要排序呢? 奇怪!! 郁闷 wa. 随便构造一个满足要求就可以了吧#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator