这题不用getchar()快读
by pythoner713 @ 2019-08-22 20:35:45
@[pythoner713](/space/show?uid=142338) 我用getchar()读字符,不是快读
by Samuel_YHL @ 2019-08-22 20:38:02
@[火之意志](/space/show?uid=122000) 要不数组开大点试试
by TEoS @ 2019-08-22 20:40:08
@[TEoS](/space/show?uid=91534) 一共才70条边,26个点
by Samuel_YHL @ 2019-08-22 20:41:10
700条边,看错了
by Samuel_YHL @ 2019-08-22 20:41:46
又是一个刚学OI做网络流的%%%
by nth_element @ 2019-08-22 20:48:18
我知道了,dalao您其实不用转换大小写的,题目说要忽略小写的情况。
我之前也被坑过>_<现在应该能A了
```cpp
#include <queue>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define inf 0x3f3f3f3f
using namespace std;
struct EDGE
{
int to, next, w;
}edge[7100];
struct node
{
int u, id;
}pre[300];
int S = int('A'), T = int('Z'), head[300], cnt = 1, vis[300];
void add(int u, int v, int w)
{
edge[++cnt].next = head[u];
edge[cnt].to = v;
edge[cnt].w = w;
head[u] = cnt;
return;
}
bool bfs()
{
queue <int> q;
memset(vis, 0, sizeof vis);
memset(pre, -1, sizeof pre);
vis[S] = 1;
q.push(S);
while (!q.empty())
{
int u = q.front();
q.pop();
for (int i = head[u]; i; i = edge[i].next)
if (!vis[edge[i].to] && edge[i].w)
{
pre[edge[i].to].u = u;
pre[edge[i].to].id = i;
if (edge[i].to == T)
return 1;
vis[edge[i].to] = 1;
q.push(edge[i].to);
}
}
return 0;
}
int EK()
{
int ans = 0;
while (bfs())
{
int mn = inf;
for (int i = T; i != S; i = pre[i].u)
mn = min(mn, edge[pre[i].id].w);
for (int i = T; i != S; i = pre[i].u)
{
edge[pre[i].id].w -= mn;
edge[pre[i].id ^ 1].w += mn;
}
ans += mn;
}
return ans;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
{
char u, v;
int w;
cin >> u >> v >> w;
add(int(u), int(v), w);
add(int(v), int(u), 0);
}
printf("%d\n",EK());
return 0;
}
```
by pythoner713 @ 2019-08-22 20:48:27
@[pythoner713](/space/show?uid=142338) 多谢大佬
by Samuel_YHL @ 2019-08-22 20:50:50