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 <iostream.h> bool c[500][500]; bool v[500]; long n,m; int main() { long i,j,k; long x,y; long sum; bool ch; while (cin>>n>>m) { if ((n+m)==0) break; for (i=0;i<n;i++) { v[i]=true; for (j=0;j<n;j++) c[i][j]=false; } for (i=0;i<m;i++) { cin>>x>>y; x--;y--; c[x][y]=true; } do { ch=false; for (i=0;i<n;i++) for (j=0;j<n;j++) if (c[j][i]) for (k=0;k<n;k++) if (!c[j][k] && c[i][k]) ch=c[j][k]=true; }while(ch); sum=0; for (i=0;i<n;i++) { for (j=0;j<n;j++) if (c[i][j] && v[j]) { sum++; v[j]=false; break; } } cout<<n-sum<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator