QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93054#143. 最大流(随机数据)zsj6315#Compile Error//C++141.1kb2023-03-31 10:25:092023-03-31 10:25:11

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-31 10:25:11]
  • 评测
  • [2023-03-31 10:25:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define ull unsigned long long
#define ll long long
#define mod 998244353
#define N 105
#define M 10005
int n,m,S,T;
int edt=1,head[N],to[M],nx[M],ew[M];
int q[N],cur[N],d[N];
bool bfs(){
	memset(d,-1,sizeof d);
	cur[S]=head[S];d[S]=0;
	int hh=0,tt=0;
	q[0]=S;
	while(hh<=tt){
		int u=q[hh++];
		for(int ed=head[u];ed;ed=nx[ed]){
			int v=to[ed];
			if(ew[ed]&&d[v]==-1){
				d[v]=d[u]+1;
				if(v==T)return 1;
				q[++tt]=v;
				cur[v]=head[v];
			}
		}
	}
	return 0;
}
int dfs(int u,int li){
	if(u==T)return li;
	int flow=0;
	for(int ed=cur[u];ed&&flow<li;ed=nx[ed]){
		int v=to[ed];
		if(ew[ed]&&d[v]==d[u]+1){
			int t=dfs(v,min(ew[ed],li-flow));
			if(!t)d[v]=-1;
			ew[ed]-=t,ew[ed^1]+=t,flow+=t; 
		}
	}
	return flow;

int dinic(){
	int flow=0,t;
	while(bfs())while(t=dfs(S,0x3f3f3f3f)flow+=t;
	return flow;
}
int main(){
	scanf("%d%d%d%d",&n,&m,&S,&T);
	fr(i,1,m){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		adde(u,v,w),adde(v,u,w);
	} 
	printf("%d\n",dinic());
	return 0;
}

详细

answer.code: In function ‘int dfs(int, int)’:
answer.code:44:10: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   44 | int dinic(){
      |          ^~
answer.code:44:10: note: remove parentheses to default-initialize a variable
   44 | int dinic(){
      |          ^~
      |          --
answer.code:44:10: note: or replace parentheses with braces to value-initialize a variable
answer.code:44:12: error: a function-definition is not allowed here before ‘{’ token
   44 | int dinic(){
      |            ^
answer.code:49:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   49 | int main(){
      |         ^~
answer.code:49:9: note: remove parentheses to default-initialize a variable
   49 | int main(){
      |         ^~
      |         --
answer.code:49:9: note: or replace parentheses with braces to value-initialize a variable
answer.code:49:11: error: a function-definition is not allowed here before ‘{’ token
   49 | int main(){
      |           ^
answer.code:58:2: error: expected ‘}’ at end of input
   58 | }
      |  ^
answer.code:31:22: note: to match this ‘{’
   31 | int dfs(int u,int li){
      |                      ^