Sangber @ 2019-08-25 08:04:04
RT
本地可以跑,但是一交上去就CE,显示说:
No valid executable file was produced by the compiler
表示很难受。。。
by Sangber @ 2019-08-25 08:05:10
代码:
/*--------------------------------
Code name: cpp.cpp
Author: The Ace Bee
This code is made by The Ace Bee
--------------------------------*/
#include <queue>
#include <cstdio>
#include <cstring>
#define rg register
#define file(x) \
freopen(x".in", "r", stdin); \
freopen(x".out", "w", stdout);
const int $ = 40010;
const int _ = 5000010;
const int INF = 2147483647;
const int dx[] = {1, -1, 2, -2, 1, -1, 2, -2};
const int dy[] = {-2, -2, -1, -1, 2, 2, 1, 1};
using namespace std;
inline int read() {
int s = 0; bool f = false; char c = getchar();
while (c < '0' || c > '9') f |= (c == '-'), c = getchar();
while (c >= '0' && c <= '9') s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
return f ? -s : s;
}
int tot = 1, head[$], nxt[_], ver[_], cap[_];
inline void Add_edge(int u, int v, int d)
{ nxt[++tot] = head[u], head[u] = tot, ver[tot] = v, cap[tot] = d; }
inline void link(int u, int v, int d) { Add_edge(u, v, d), Add_edge(v, u, 0); }
int s, t, n, m, dep[$], cur[$], f[$][$];
inline int cg(int i, int j) { return (i - 1) * n + j; }
inline int bfs() {
queue < int > q;
memset(dep, 0, sizeof dep);
dep[s] = 1, q.push(s);
while (!q.empty()) {
int u = q.front(); q.pop();
for (rg int i = head[u]; i; i = nxt[i]) {
int v = ver[i];
if (dep[v] == 0 && cap[i] > 0)
dep[v] = dep[u] + 1, q.push(v);
}
}
return dep[t] > 0;
}
inline int dfs(int u, int flow) {
if (u == t) return flow;
for (rg int& i = cur[u]; i; i = nxt[i]) {
int v = ver[i];
if (dep[v] == dep[u] + 1 && cap[i] > 0) {
int res = dfs(v, min(flow, cap[i]));
if (res) { cap[i] -= res, cap[i ^ 1] += res; return res; }
}
}
return 0;
}
inline int Dinic() {
int res = 0;
while (bfs()) {
for (rg int i = 1; i <= t; ++i) cur[i] = head[i];
while (int d = dfs(s, INF)) res += d;
}
return res;
}
main() {
// file("cpp");
n = read(), m = read(), s = n * n + 1, t = n * n + 2;
for (rg int i = 1; i <= m; ++i) f[read()][read()] = 1;
for (rg int i = 1; i <= n; ++i)
for (rg int j = 1; j <= n; ++j)
if (!f[i][j]) {
if ((i + j) & 1)
link(s, cg(i, j), 1);
else
link(cg(i, j), t, 1);
}
for (rg int i = 1; i <= n; ++i)
for (rg int j = 1; j <= n; ++j)
if ((i + j) & 1)
for (rg int k = 0; k < 8; ++k) {
int di = i + dx[k], dj = j + dy[k];
if (di < 1 || di > n || dj < 1 || dj > n) continue;
if (!f[di][dj]) link(cg(i, j), cg(di, dj), INF);
}
printf("%d\n", n * n - m - Dinic());
return 0;
}
by Suphx @ 2019-08-25 08:07:04
“freopen(x".out", "w", stdout);”---x在外面。。。
by Sangber @ 2019-08-25 08:07:08
懂了,此贴终结
by Suphx @ 2019-08-25 08:07:54
QwQ
by Sangber @ 2019-08-25 08:08:10
@空与白之灵 这是常规操作。。。
具体问题已经发现,就是我的
by Suphx @ 2019-08-25 08:08:44
@Takisaki_Kurumi 哦(我没学dinic...)
by Suphx @ 2019-08-25 08:09:01
所以。。。%%%Takisaki_Kurumi
by Sangber @ 2019-08-25 08:09:42
好的我已经
by Suphx @ 2019-08-25 08:10:09
%%%%%%%%%%%