2 solutions
-
1
#include<bits/stdc++.h> using namespace std; const int N=110; int n,m,k; int match[N]; bool g[N][N],st[N]; bool find(int x) { for(int i=1;i<m;i++) { if(!i[st]&&i[x[g]]) { i[st]=true; if(i[match]==0||find(i[match])) { i[match]=x; return true; } } } return false; } int main() { while(cin>>n,n) { cin>>m>>k; memset(g,false,sizeof g); memset(match,0,sizeof match); while(k--) { int t,a,b; cin>>t>>a>>b; if(a&&b) { b[a[g]]=true; } } int res=0; for(int i=1;i<n;i++) { memset(st,false,sizeof st); if(find(i)) { res++; } } cout<<res<<"\n"; } return 0; }
Information
- ID
- 354
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 10
- Tags
- # Submissions
- 8
- Accepted
- 5
- Uploaded By