标签:typedef ted sep == miss code poj cstring data
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 22905 | Accepted: 12421 |
Description
Input
Output
Sample Input
3 4 1 1 1 3 2 2 3 2
Sample Output
2
Hint
Source
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> #include<set> #include<map> #include<queue> #include<stack> #include<vector> using namespace std; #define PI acos(-1.0) typedef long long ll; typedef pair<int,int> P; const int maxn=1e5+100,maxm=1e5+100,inf=0x3f3f3f3f,mod=1e9+7; const ll INF= 1e13+7; priority_queue<P,vector<P>,greater<P> >q; vector<int>G[maxn]; int vis[maxn],cy[maxn]; int dfs(int u) { for(int i=0; i<G[u].size(); i++) { int v=G[u][i]; if(vis[v]) continue; vis[v]=true; if(cy[v]==-1||dfs(cy[v])) { cy[v]=u; return true; } } return false; } int solve(int n) { int ans=0; memset(cy,-1,sizeof(cy)); for(int i=1; i<=n; i++) { memset(vis,0,sizeof(vis)); ans+=dfs(i); } return ans; } int main() { int n,k; scanf("%d%d",&n,&k); for(int i=1; i<=k; i++) { int x,y; scanf("%d%d",&x,&y); G[x].push_back(y); } cout<<solve(n)<<endl; return 0; }
标签:typedef ted sep == miss code poj cstring data
原文地址:http://www.cnblogs.com/GeekZRF/p/7224988.html