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 |
Re:依旧WA。。。。。。。。。。。。。。。。。。。。到底哪里还有错啊?In Reply To:WA到我死 Posted by:iShowFun at 2009-02-07 09:47:59 #include<stdio.h> #include<iostream> #include<algorithm> #define Max 25 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() { while(1==scanf("%d",&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++) { if(lake[i2].last>=lakenum) { ispos=false; break; } int i3; for(i3=1;i3<=lakenum;i3++) { if(i3==i2) { if(i2==lakenum&&lake[i2].last>0) { ispos=false; break; } 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) 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