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 |
纯暴力,水水更健康= =#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <vector> #include <queue> #include <cmath> #include <stack> using namespace std; struct node{ int e, num; }a[15]; bool cmp(node a,node b){ return a.num>b.num; } main() { int n; int i, j, k, t; int b[15][15]; cin>>t; while(t--){ scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a[i].num); a[i].e=i; } int ci=0; memset(b,0,sizeof(b)); while(ci<n-1){ ci++; sort(a,a+n,cmp); for(i=1;i<=a[0].num;i++) a[i].num--,b[a[0].e][a[i].e]=b[a[i].e][a[0].e]=1; a[0].num=0; } int f=1; for(i=0;i<n;i++){ if(a[i].num<0){ f=0;break; } } if(!f) printf("NO\n\n"); else { printf("YES\n"); for(i=0;i<n;i++){ printf("%d",b[i][0]); for(j=1;j<n;j++){ printf(" %d",b[i][j]); } cout<<endl; } cout<<endl; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator