bool check(const double &answer) { double ret = 0; int tot = 0; std::fill(h + 1, h + n * n + n + 2 + 1, t = 0); for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) { if (p[j] > p[i]) { tot++; } } } int S = tot + n + 1, T = tot + n + 2, B = tot; tot = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j < i; j++) if (p[j] > p[i]) { addEdge(S, ++tot, 1); addEdge(tot, B + i, INF); addEdge(tot, B + j, INF); } } for (int i = 1; i <= n; i++) { addEdge(B + i, T, answer); } double maxflow = Maxflow_Isap(S, T, n * n + n + 2 + 10); return dcmp(tot - maxflow) > 0; }
double check(const double &answer) { std::fill(h + 1, h + n + 1, t = 0); for (int i = 1; i <= m; i++) { addEdge(r[i].x, r[i].y, (int)std::min(1.0 * INF, floor(1.0 * r[i].c / answer))); } return Maxflow_Isap(1, n, n) >= x; }