QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#283391#1359. Setting MapstomlusuCompile Error//C++142.6kb2023-12-14 16:04:262023-12-14 16:04:26

Judging History

This is the latest submission verdict.

  • [2023-12-14 16:04:26]
  • Judged
  • [2023-12-14 16:04:26]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const long long inf = 1e18;
int n, m, k, c[205];
struct Edge{
	int v, nxt; long long w;
	Edge(int x, int y, long long z){v = x, nxt = y, w = z;}
	Edge(){}
};
struct MF{
	Edge e[100005]; int head[2005], cnt = 0, S, T, dep[2005], nw[2005];
	void addedge(int u, int v, long long w){
		e[cnt] = Edge(v, head[u], w), head[u] = cnt++;
		e[cnt] = Edge(u, head[v], 0), head[v] = cnt++;
	}
	bool bfs(){
		for(int i = 1; i <= 2 * k * n; i++) dep[i] = 0;
		queue<int> q; q.push(S), dep[S] = 1;
		while(!q.empty()){
			int x = q.front(); q.pop();
			for(int i = head[x]; i != -1; i = e[i].nxt)
				if(!dep[e[i].v] && e[i].w){
					dep[e[i].v] = dep[x] + 1, q.push(e[i].v);
					if(e[i].v == T) return true;
				}
		}
		return false;
	}
	long long dfs(int x, long long flow){
		if(x == T) return flow;
		if(!flow) return 0;
		long long lst = flow, ret;
		for(int i = nw[x]; i != -1; i = e[i].nxt){
			nw[x] = i;
			if(e[i].w && (dep[e[i].v] == dep[x] + 1)){
				ret = dfs(e[i].v, min(e[i].w, lst));
				e[i].w -= ret, lst -= ret, e[i ^ 1].w += ret;
			}
		}
		if(!lst) dep[x] = 0;
		return flow - lst;
	}
	long long dinic(){
		long long ans = 0;
		while(bfs()){for(int i = 1; i <= 2 * n * k; i++) nw[i] = head[i]; ans = ans + dfs(S, 3e9);}
		return ans;
	}
	MF(){memset(head, -1, sizeof(head));}
} M;
int in[205][6], ot[205][6];
long long cnt; bool vis[2005];
vector<int> ans;
void cal(){
	queue<int> q; q.push(M.S), vis[M.S] = 1;
	while(!q.empty()){
		int x = q.front(); q.pop();
		for(int i = M.head[x]; i != -1; i = M.e[i].nxt)
			if(!vis[M.e[i].v] && M.e[i].w)
				vis[M.e[i].v] = true, q.push(M.e[i].v);
	}
}
signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> k >> M.S >> M.T;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < k; j++) in[i][j] = ++cnt, ot[i][j] = ++cnt;
	for(int i = 1, x; i <= n; i++){
		cin >> x;
		for(int j = 0; j < k; j++) M.addedge(in[i][j], ot[i][j], x);
		for(int j = 0; j < k - 1; j++)
			for(int t = j + 1; t < k; t++) M.addedge(in[i][j], ot[i][t], 2e9);
	}
	for(int i = 1, u, v; i <= m; i++){
		cin >> u >> v;
		for(int j = 0; j < k; j++) M.addedge(ot[u][j], in[v][j], 2e9);
	}
	M.S = in[M.S][0], M.T = ot[M.T][k - 1], cnt = M.dinic();
	if(cnt > 2e9){cout << -1 << endl; return 0;}
	cnt = 0; cal();
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < k; j++)
			if(M.vis[in[i][j]] && (!M.vis[ot[i][j]])) cnt++, ans.push_back(i);
	cout << cnt << endl;
	for(int i = 0; i < cnt; i++) cout << ans[i] << " ";
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:83:30: error: ‘struct MF’ has no member named ‘vis’
   83 |                         if(M.vis[in[i][j]] && (!M.vis[ot[i][j]])) cnt++, ans.push_back(i);
      |                              ^~~
answer.code:83:51: error: ‘struct MF’ has no member named ‘vis’
   83 |                         if(M.vis[in[i][j]] && (!M.vis[ot[i][j]])) cnt++, ans.push_back(i);
      |                                                   ^~~