QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#472399#8865. CakesPetroTarnavskyi#Compile Error//C++202.7kb2024-07-11 16:12:182024-07-11 16:12:19

Judging History

你现在查看的是最新测评结果

  • [2024-07-11 16:12:19]
  • 评测
  • [2024-07-11 16:12:18]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const LL LINF = 1e18;

struct Graph
{
	struct Edge
	{
		int from, to;
		LL cap, flow;
	};
	
	int n;
	vector<Edge> edges;
	vector<VI> g;
	VI d, p;
	
	void init(int _n)
	{
		n = _n;
		edges.clear();
		g.clear();
		g.resize(n);
		d.resize(n);
		p.resize(n);
	}
	void addEdge(int from, int to, LL cap)
	{
		assert(0 <= from && from < n);
		assert(0 <= to && to < n);
		assert(0 <= cap);
		g[from].PB(SZ(edges));
		edges.PB({from, to, cap, 0});
		g[to].PB(SZ(edges));
		edges.PB({to, from, 0, 0});
	}
	int bfs(int s, int t)
	{
		fill(ALL(d), -1);
		d[s] = 0;
		queue<int> q;
		q.push(s);
		while (!q.empty())
		{
			int v = q.front();
			q.pop();
			for (int e : g[v])
			{
				int to = edges[e].to;
				if (edges[e].flow < edges[e].cap && d[to] == -1)
				{
					d[to] = d[v] + 1;
					q.push(to);
				}
			}
		}
		return d[t];
	}
	LL dfs(int v, int t, LL flow)
	{
		if (v == t || flow == 0)
			return flow;
		for (; p[v] < SZ(g[v]); p[v]++)
		{
			int e = g[v][p[v]], to = edges[e].to;
			LL c = edges[e].cap, f = edges[e].flow;
			if (f < c && (to == t || d[to] == d[v] + 1))
			{
				LL push = dfs(to, t, min(flow, c - f));
				if (push > 0)
				{
					edges[e].flow += push;
					edges[e ^ 1].flow -= push;
					return push;
				}
			}
		}
		return 0;
	}
	LL flow(int s, int t)
	{
		assert(0 <= s && s < n);
		assert(0 <= t && t < n);
		assert(s != t);
		LL flow = 0;
		while (bfs(s, t) != -1)
		{
			fill(ALL(p), 0);
			while (true)
			{
				LL f = dfs(s, t, LINF);
				if (f == 0)
					break;
				flow += f;
			}
		}
		return flow;
	}
} G;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int g, c, t;
	cin >> g >> c >> t;
	
	VI cc(c);
	FOR (i, 0, c)
		cin >> cc[i];
	VI gc(g);
	FOR (i, 0, g)
		cin >> gc[i];
	VI tc(t);
	FOR (i, 0, t)
		cin >> tc[i];
		
	FOR (i, 0, c)
	{
		FOR (j, 0, g)
		{
			int a;
			cin >> a;
			cc[i] -= gc[j] * a;
		}
	}	
	G.init(c + t + 2);
	int S = c + t;
	int T = S + 1;
	
	LL ans = 0;
	FOR (i, 0, c)
	{
		if (cc[i] > 0)
		{
			G.addEdge(S, i, cc[i]);
			ans += cc[i];
		}
	}
	FOR (i, 0, t)
		G.addEdge(i + c, T, tc[i]);
	FOR (i, 0, c)
	{
		int n;
		cin >> n;
		FOR (j, 0, n)
		{
			int b;
			cin >> b;
			b--;
			G.addEdge(i, b + c, LINF);
		}
	}
	
	cout << ans - G.flow(S, T) << '\n';
	
	return 0;
}

77474

Details

answer.code:178:1: error: expected unqualified-id before numeric constant
  178 | 77474
      | ^~~~~