改得和题解几乎一样都错?!

P2055 [ZJOI2009] 假期的宿舍

~~看看题解A了没先~~
by xenonex @ 2018-08-19 19:45:40


@[y2823774827y](/space/show?uid=88804) chen_zhe手滑不小心通过了这个不合格的题解(逃
by 波风水门 @ 2018-08-19 19:50:46


emm题解过了,两位dalao有没有兴趣试试找不同 @[xenonex](/space/show?uid=86061) @[四代目火影](/space/show?uid=81710)
by y2823774827y @ 2018-08-19 19:53:42


@[y2823774827y](/space/show?uid=88804) 试一下吧
by 波风水门 @ 2018-08-19 19:55:26


@[y2823774827y](/space/show?uid=88804) 你的输出反了吧
by 波风水门 @ 2018-08-19 19:59:46


没反吧 @[四代目火影](/space/show?uid=81710) ```cpp if(k==cnt) printf("^_^\n"); else printf("T_T\n"); ``` ```cpp if(sum==tot) cout<<"^_^"<<endl; else cout<<"T_T"<<endl; ```
by y2823774827y @ 2018-08-19 20:03:47


@[y2823774827y](/space/show?uid=88804) ~~数组开大就过了~~
by xenonex @ 2018-08-19 20:11:03


fc 一下
by kraylas @ 2018-08-19 20:17:30


终于找到了错误的地方!c数组没有初始化
by y2823774827y @ 2018-08-19 21:38:29


碰到了和你一样的问题,改得和题解一样 还是全wa ```cpp #include<cstdio> #include<cstring> using namespace std; struct node { int v; int next; }bed[10000]; int cnt=1; int first[100]; int book[100],match[100]; int home[100],student[100]; int n,num,sum; void add(int ,int ); int dfs(int); int main() { int t; scanf("%d",&t); for(int i=1;i<=t;i++) { num=0; memset(first,-1,sizeof(first)); /*memset(home,0,sizeof(home)); memset(student,0,sizeof(student));*/ scanf("%d",&n); for(int j=1;j<=n;j++) scanf("%d",&student[j]); for(int j=1;j<=n;j++) { scanf("%d",&home[j]); if(student[j] and home[j]==0)//如果是不回家的学生 add(j,j);//睡自己的床 } for(int j=1;j<=n;j++) if((student[j] and !home[j]) or !student[j]) num++;//统计要床的人数 int rub; for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) { scanf("%d",&rub); if(rub and student[k])//如果认识的人是学生 add(j,k); } memset(match,0,sizeof(match)); sum=0; for(int j=1;j<=n;j++) if((student[j] and home[j]==0) or !student[j]) { memset(book,0,sizeof(book)); if(dfs(i)) sum++; } if(sum==num) printf("^_^\n"); else printf("T_T\n"); } getchar(); getchar(); return 0; } void add(int u,int v) { bed[cnt].v=v; bed[cnt].next=first[u]; first[u]=cnt; cnt++; } int dfs(int u) { for(int i=first[u];i!=-1;i=bed[i].next) { int w=bed[i].v; if(!book[w]) { book[w]=1; if(!match[w] or dfs(match[w])) { match[w]=u; return 1; } } } return 0; } ```
by 旅人杜 @ 2018-11-08 11:35:40


| 下一页