Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstring>
- #include<queue>
- using namespace std;
- const int maxe=(1<<14),maxel=64,maxn=(1<<12);
- struct edge
- {
- int to,cap,next;
- edge(){}
- edge(int _to,int _cap,int _next)
- {
- to=_to;
- cap=_cap;
- next=_next;
- }
- };
- edge e[maxe];int bre;
- int n,m,head[maxn],ptr[maxn],S,T,F;
- int lvl[maxn],path[maxe],sz;
- int a[maxel][maxel],Sum_of_a;
- void read()
- {
- cin>>n>>m;
- string s;
- for(int i=1;i<=n;++i)
- {
- cin>>s;
- for(int j=0;j<m;++j)
- {
- switch(s[j])
- {
- case 'H':a[i][j+1]=1;
- break;
- case 'O':a[i][j+1]=2;
- break;
- case 'N':a[i][j+1]=3;
- break;
- case 'C':a[i][j+1]=3;
- break;
- }
- Sum_of_a+=a[i][j+1];
- }
- }
- }
- void add_edge(int from,int to,int cap)
- {
- edge[bre]=edge(to,cap,head[from]);
- head[from]=bre;bre++;
- }
- void init_graph()
- {
- memset(head,-1,sizeof(head));
- S=0;
- T=n*m+1;
- int cur,to;
- for(int i=1;i<=n;++i)
- for(int j=1;j<=m;++j)
- {
- cur=(i-1)*m+j;
- if(i%2==j%2)
- {
- add_edge(S,cur,a[i][j]);
- add_edge(cur,S,0);
- if(1<i)
- {
- to=(i-2)*m+j;
- add_edge(cur,to,1);
- add_edge(to,cur,0);
- }
- if(i<n)
- {
- to=i*m+j;
- add_edge(cur,to,1);
- add_edge(to,cur,0);
- }
- if(1<j)
- {
- to=(i-1)*m+j-1;
- add_edge(cur,to,1);
- add_edge(to,cur,0);
- }
- if(j<m)
- {
- to=(i-1)*m+j+1;
- add_edge(cur,to,1);
- add_edge(to,cur,0);
- }
- }
- else
- {
- add_edge(cur,T,a[i][j]);
- add_edge(T,cur,0);
- }
- }
- }
- bool BFS()
- {
- memset(lvl,0,sizeof(lvl));
- lvl[T]=1;
- queue<int>q;
- q.push(T);
- int w,i;
- while(!q.empty())
- {
- w=q.front();
- q.pop();
- for(i=head[w];i!=-1;i=e[i].next)
- if(!lvl[e[i].to]&&e[i^1].cap>0)
- {
- q.push(e[i].to);
- lvl[e[i].to]=lvl[w]+1;
- }
- }
- return lvl[S];
- }
- void Dinitz()
- {
- }
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement