标签:div 算法 nod 删除 游戏 define scan script logs
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5142 Accepted Submission(s): 3026
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 0x3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int a[110][110]; int n,m,k; struct Node { int x; int y; }node[10006]; int vis[109]; int pos[109]; bool find(int x) { for(int i=1;i<=m;i++) { if(a[x][i] && !vis[i]) { vis[i]=1; if(!pos[i] || find(pos[i])) { pos[i]=x; return true; } } } return false; } int main() { int cast=0; while(scanf("%d%d%d",&n,&m,&k)!=EOF) { int ans=0,cnt,inf=0; memset(a,0,sizeof(a)); memset(pos,0,sizeof(pos)); for(int i=0;i<k;i++) { scanf("%d%d",&node[i].x,&node[i].y); a[node[i].x][node[i].y]=1; } for(int i=1;i<=n;i++)//最大放车的数量 { memset(vis,0,sizeof(vis)); if(find(i)) ans++; } for(int i=0;i<k;i++) { a[node[i].x][node[i].y]=0;//删除边 memset(pos,0,sizeof(pos)); cnt=0; for(int j=1;j<=n;j++) { memset(vis,0,sizeof(vis)); if(find(j)) cnt++; } if(cnt!=ans) inf++; a[node[i].x][node[i].y]=1;//判断完后 恢复该边 } printf("Board %d have %d important blanks for %d chessmen.\n",++cast,inf,ans); } return 0; }
标签:div 算法 nod 删除 游戏 define scan script logs
原文地址:http://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7295976.html