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<stdio.h> #include<iostream> #include<algorithm> #define Max 11 using namespace std; typedef struct { int sufix; int neib[Max]; int neibnum; int last; }stlake; stlake lake[Max]; int casenum; int lakenum; int tmp; bool ispos; void ini() { for(int i=1;i<=lakenum;i++) { lake[i].neibnum=0; lake[i].sufix=0; lake[i].last=0; for(int j=0;j<Max;j++) { lake[i].neib[j]=0; } } ispos=true; } bool cmp(stlake a,stlake b) { return a.neibnum>b.neibnum; } bool cmp1(stlake a,stlake b) { return a.sufix<b.sufix; } int main() { cin>>casenum; for(int c=0;c<casenum;c++) { if(c) printf("\n"); cin>>lakenum; ini(); for(int i1=1;i1<=lakenum;i1++) { scanf("%d",&tmp); lake[i1].neibnum=tmp; lake[i1].last=tmp; lake[i1].sufix=i1; } sort(lake+1,lake+1+lakenum,cmp); for(int i2=1;i2<=lakenum;i2++) { int i3; for(i3=1;i3<=lakenum;i3++) { if(i3==i2) continue; if(lake[i2].last==0) break; if(lake[i3].last&&lake[i3].neib[lake[i3].sufix]!=1) { lake[i3].last--; lake[i2].last--; lake[i2].neib[lake[i3].sufix]=1; lake[i3].neib[lake[i2].sufix]=1; } } if(i3>=lakenum&&lake[i2].last>0) { ispos=false; break; } } if(!ispos||lakenum==0) printf("NO\n"); else { printf("YES\n"); sort(lake+1,lake+1+lakenum,cmp1); for(int j=1;j<=lakenum;j++) { for(int j1=1;j1<=lakenum;j1++) { if(j1!=1) printf(" "); printf("%d",lake[j].neib[j1]); } printf("\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