有毒把这个题,我想问问这两个写法有何不同

P2071 座位安排

woc 发错了 第二个程序应该是 ### ```cpp bool fate(int x){ for(int i=0;i<e[x].size();i++){ int t=e[x][i]; if(!vis[t]){ vis[t]=1; if(master[t]==-1||fate(master[t])){ master[t]=x; return 1; } } } return 0; } ```
by bymlg001 @ 2017-09-23 22:35:40


```cpp #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=4008; bool f[maxn][maxn],book[maxn]; int match[maxn],n,u,v,ans=0; inline char getc() { static char buf[1<<14],*p1=buf,*p2=buf; return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++; } inline int read() { int data=0,w=1; char ch=0; while(ch!='-' && (ch<'0' || ch>'9')) ch=getchar(); if(ch=='-') w=-1,ch=getchar(); while(ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar(); return data*w; } int dfs(int u) { for(int i=1;i<=n;i++) { if(!book[i]&&f[u][i]) { book[i]=1; if(!match[i]||dfs(match[i])) { match[i]=u; return 1; } } } return 0; } int main() { n=read(); for(int i=1;i<=2*n;i++) { u=read(),v=read(); f[i][u]=f[i][v]=1; } for(int i=1;i<=2*n;i++) { memset(book,0,sizeof(book)); if(dfs(i)) ans++; } printf("%d",ans); } ```
by Explorer_CYC @ 2018-03-11 14:33:53


@[灿小花](/space/show?uid=51213) 4000*4000的数组都没有爆??!!!
by syh0313 @ 2018-08-03 20:07:21


没。。bool比较小QwQ
by Explorer_CYC @ 2018-08-05 18:16:07


|