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 |
怎么我不用这个构图也能AC啊????不用if(x * y != 0) map[x][y] = 1; 也能AC 的? #include<iostream> using namespace std; #define maxn 1000 int N, M, uN; bool g[maxn][maxn]; int xM[maxn], yM[maxn]; bool chk[maxn]; bool find(int u) { int v; for(v=1; v<=M; v++) if(g[u][v] && !chk[v]) { chk[v] = true; if(yM[v] == -1 || find(yM[v])) { yM[v] = u; xM[u] = v; return true; } } return false; } int MaxMatch() { int u, ret = 0; memset(xM, -1, sizeof(xM)); memset(yM, -1, sizeof(yM)); for(u= 1;u<=N; u++) { if(xM[u] == -1) { memset(chk, false, sizeof(chk)); if(find(u)) ret++; } } return ret; } int main() { int i, id, k, x, y, res; while(scanf("%d%d%d",&N, &M, &k) && N) { memset(g, 0, sizeof(g)); for(i=0; i<k; i++) { scanf("%d%d%d",&id, &x, &y); //if(x * y != 0) g[x][y] = 1; } //uN = N; res = MaxMatch(); printf("%d\n",res); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator